Q

Sorting a clob column

I'm trying to sort a column type asc as well as desc. I'm able to sort the clob column desc but not able to sort it asc. Can you please help me out?

I'm trying to sort a column type asc as well as desc. I'm able to sort the clob column desc but not able to sort...

it asc. Can you please help me out? Please find below the sample query that I used.

select * from TAbleA A where A.col1='XXX'
order by dbms_lob.substr(clobCol, 1, dbms_lob.getlength(clobCol)) desc

Here clobcol is the clob column with which I wanted to sort.

In 9i release 2, the parameters in dbms_lob.substr is ordered differently then in a substr function. In substr the parameter order is: substr (string, position, length). In dbms_lob.substr the parameter order is: dbms_lob.substr (lob_locator, length, position). Therefore, your SQL will sort correctly if your function looks like this:

dbms_lob.substr(clobCol, dbms_lob.getlength(clobCol), 1) asc
This was last published in December 2006

Dig Deeper on Using Oracle PL-SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close