×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Is there any way to write a select statement for distinct when there is a CLOB field?
2

Is there any way to write a select statement for distinct when there is a CLOB field?

Is there any way to write a select statement for distinct when there is a CLOB field?

(OP)
"SELECT DISTINCT id, description FROM table" doesn't work because description is a CLOB field.

Thanks for your help!

RE: Is there any way to write a select statement for distinct when there is a CLOB field?

It may be a bit limiting, but you might try:

CODE

SELECT DISTINCT id, dbms_lob.substr(description,500,1) FROM table; 
For this to be useful, you will need to know how long a string in your CLOB has to be to determine distinctness. This example assumes 500 characters will be sufficient.

RE: Is there any way to write a select statement for distinct when there is a CLOB field?

(OP)
Hi carp,

Sorry for the late reply. So far, the field has 3,054 characters but it could increase and we need to show all of the CLOB.

Thanks

RE: Is there any way to write a select statement for distinct when there is a CLOB field?

Personally I would have a column in the table with the clob to hold a hash value that could be used to check for a distinct value in the clob. Maintain the hash column by having a trigger on insert or update of the clob column and use DBMS_CRYPTO.HASH to calculate the hash. I would not use a virtual column because everytime you looked at the data it would have to fire the DBMS_CRYPTO.HASH. By using a trigger and an actual column it would only fire when necessary

Bill
Lead Application Developer
New York State, USA

RE: Is there any way to write a select statement for distinct when there is a CLOB field?

I also face the same problem. From Contact Arlo support, I find a solution. Still, I can't solve the problem.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close