Ask the Expert

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? 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.

    Requires Free Membership to View

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 first published in December 2006

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: