I have a table that contains an xml document stored as a clob.
TabA
----
Name varchar2(30) (PK)
Definition clob
other attributes
Note: “Definition” is the clob column that stores the XML.
Typical data volume: 1500 rows.
My requirement is to do some kind of recon and only process those rows on a daily basis that have undergone change to the XML and process those rows that have come in as new.
Identifying rows that came in new and processing only them is easy and can be done with “minus” on the name.
But, is there a good way to identify the XMLs in the existing rows that have undergone change ?
For eg: If an element within an XML has been removed or its attributes changed from the previous day, then I should be able to process that “Name” row.
Example of the typical XML in the table:
<?xml version="1.0" encoding="UTF-8"?>
<dataMart asOfDriver="EFFECTIVE_DATE" chainedData="false" classification="" convertUsingFxRate="false" coreEntityIndicator="false" createdAt="2011-12-22T17:41:11.002" createdBy="user1" description="" entitled="false" entitlementDriver="false" hierarchicalFlag="false" innerJoin="false" intent="Intermediate" lastUpdatedAt="2012-07-26T16:11:42.424" lastUpdatedBy="p459807" martType="SPOT" martUsage="Persistent" ownerRole="Meta Model SSC" preAggregatedData="false" referenceDataIndicator="false" retention="" rollupFunction="" staticAggregationOnly="false" status="ACTIVE" tags="">
<name>Name1</name>
<sources>
<source isDefault="false" name="S1"></source>
</sources>
<rowType-mapping>
<rowType identifier="0">
<element alias="E1" name="E1" source="" sourceAlias="" sourceType="system" trackSource="false">
<description localDescription="false"></description>
<validationRule type="None"></validationRule>
<mapping columnName="E1" function="" tableName="TABA"></mapping>
<Opaque />
</element>
More element tags
...<element> </element>
</rowType>
</rowType-mapping>
<parameters>
<parameter filter="N" name="P1">
<![CDATA[PM]]>
</parameter>
</parameters>
</dataMart>
Any pointers would be much appreciated.
I would recommend using trigger to log changed items to another table. Process what ever was logged in the log table for a particular day.
On how to compare two XMLs refer to this