?
Solved

How do I compare two strings/CLOB in Oracle 9.2?

Posted on 2005-03-03
3
Medium Priority
?
4,907 Views
Last Modified: 2010-03-22

How do I compare two strings/CLOBs in Oracle 9.2?
I have a new CLOB value and I need to compare it with another CLOB value in a table.  If the new and old values are different, I need to update the table.  Otherwise, I move on to the next record.

Is there a PL/SQL function that can compare two CLOBs with each other?

Thanks,
Troy
0
Comment
Question by:tdsimpso
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:tdsimpso
ID: 13453014
Would it be better if I convert the two CLOB's into an Integer Value and compare the values?

Thanks,
Troy
0
 
LVL 23

Accepted Solution

by:
paquicuba earned 2000 total points
ID: 13453201
SQL> SELECT * FROM CLOB1
  2  /

COL1
--------------------------------------------------------------------------------
ABCDEFGHIJKL
ABCDEFGHIJK
LMNOPQRST

Elapsed: 00:00:00.00
SQL> SELECT * FROM CLOB2
  2  /

COL1
--------------------------------------------------------------------------------
ABCDEFGHIJK
LMNOPQRST
LM

Elapsed: 00:00:00.00
SQL> SELECT * FROM(
  2  SELECT DECODE(DBMS_LOB.COMPARE(A.COL1,B.COL1),0,A.COL1,NULL) COL1 FROM CLOB1 A, CLOB2 B)
  3  WHERE COL1 IS NOT NULL
  4  /

COL1
--------------------------------------------------------------------------------
ABCDEFGHIJK
LMNOPQRST

Elapsed: 00:00:00.00
0
 
LVL 23

Expert Comment

by:paquicuba
ID: 13453948
 1  SELECT A.COL1
  2  FROM CLOB1 A, CLOB2 B
  3* WHERE DBMS_LOB.COMPARE(A.COL1,B.COL1)= 0
SQL> /

COL1
--------------------------------------------------------------------------------
ABCDEFGHIJK
LMNOPQRST
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question