RE: Compare CLOB's and hilite difference

From: Herald ten Dam <Herald.ten.Dam_at_superconsult.nl>
Date: Mon, 30 Mar 2009 12:14:18 +0200
Message-ID: <BACE06B587FB3C47AC31296417C11434016BE355572B_at_thnms004.TheHumanNetwork.local>



For a quick compare you can maybe use a hash function, for example dbms_crypto.hash.

The package DBMS_LOB has a compare function. the input are both CLOB's and you get the first difference position back, zero if both are the same. You can loop through the clobs with this function and set the offset in the compare to the before found value.

Herald ten Dam
Superconsult



Van: oracle-l-bounce_at_freelists.org [oracle-l-bounce_at_freelists.org] namens Bill Ferguson [wbfergus_at_gmail.com] Verzonden: zaterdag 28 maart 2009 15:59
Aan: oracle-l_at_freelists.org
Onderwerp: Compare CLOB's and hilite difference

Does anybody have any code they could share that compares two CLOB's and hilites the differences?

My app stores a 'history' of the entire record (with all sub-table data) in an XML-typ CLOB field. I'd like to be able to do something similar to Wikipedia, where the users select two records to compare, and have the differences hilited.

The CLOB's are stored in the same table, along with other info, i.e. userid, timestamp, dep_id (the tie to the master record), and a sequence I use for the PK in this table. Each line in the CLOB is terminated with a CHR(10).

The CLOBS are usually around 68K each, and I'm having a devil of a time looping around through each CLOB and comparing the results on those that are over 32K in size.

I realize the above is really basic, so more info can be provided if needed. I started with just a procedure, but that quickly became extremely difficult to follow, so I started on trying to rewrite into a package. Then I figured I might as well see if somebody has already 'invented' something similar so I didn't have to reinvent the wheel.

Thanks.

--

Received on Mon Mar 30 2009 - 05:14:18 CDT

Original text of this message