Detecting change in xml structure stored as clob [closed] - oracle

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
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

It would only be possible if you keep a record of your previous (old) xml in a log or temp table before updating the New XML.
By the looks of the question, it seems that you not only want to compare the XML with its previous version but also find out "what has changed?".
A good way to compare and find what has changed is to do a diff between the old and new XML. Here is a package which does a diff on CLOB. See if you can use it to fit your needs.
Or
You can convert the CLOB to Varchar using dbms_lob.substr( clob_column, for_how_many_bytes, from_which_byte ); and then do something like below to do a diff on the two new VARCHARs-
SELECT LTRIM(RTRIM(TRANSLATE('abcdef','abc',RPAD(' ',LENGTH('abcdef'))))) val
FROM dual;
VAL
----------
def

Related

How to find the date and time the order was cancelled in Magento 1.9.x

Bit of a complex question for you..
I am exporting orders from Magento 1.9.4.0 using an extention from XTENTO.
It uses XSL to build 'profiles' to all me to cycle through orders programatically and export them in a format of my choice.
I have everything working aside from pulling the correct date the order was cancelled. I can see that in Magento this date appears to be in the table 'sales_flat_order_status_history'.
Looking at the table i can see the following:
sales_flat_order_status_history table
And the XSL I have been using is below..
XSL query
It IS finding a date; but it is finding the LAST update to the order and pulling the created_at value.
Does anyone know how I could find the FIRST timestamp where the order was in a cancelled state using the XSL notation?
The documentation for the XSL engine is available here, if helpful: https://support.xtento.com/wiki/Magento_Extensions:Magento_Order_Export_Module#2.29_Export_Fields
Many thanks
This seems to be hardcoded on your module files.
You could be able to change the query it is making to the database. I can't give complete guidance since I do not have the module files to look at.
Try opening the module folder in some code editor and search for something like:
Mage::getModel('sales/order_status_history')
You will then find where the code may reside and then change the query to filter for what you want.

Hadoop in action Patent example explanation

I was going through the examples for patent data in Hadoop in action.
Could you please explain in detail about the data sets being used?
The patent citation data set
This data set contains two columns citing and cited patents. Citing column refers to the owner ID who submitted the patent? Cited column refers to the patent ID which forms the key to the second data set?
The patent description data set
There are number of fields in this data set.
To form the mapping for this two datasets, is it citing or cited column from first data set that has corresponding key in the second dataset first column (patent)?
Lets clear up some terminology related to patents to begin with.
What is citation ?
Citations are documents that are linked together when one document
mentions another as having related content
Refer to this link to understand more about patents :)
the "patent citation data set" -- This data set just mentions patent citations.
More like saying patent A uses patent B,C and D
“CITING”,”CITED”
3858241,956203
3858241,1324234
3858241,3398406
3858241,3557384
3858241,3634889
3858242,1515701
3858242,3319261
3858242,3668705
3858242,3707004
Copy pasted it from the book, so here patent number 3858242 cites (uses/refers to) 4 other patents,
patent number 3858241 cites (uses/refers to) 5 other patents
the patent description data set -- is a bit like the master table, it just holds the data for each patent.
Hopefully that clears up a few things for you.
I guess there was misunderstanding in solution of Top K records from HiA book, at section 4.7, which says:
"Top K records—Change AttributeMax.py (or AttributeMax.php) to output the entire record rather than only the maximumvalue. Rewrite it such that the MapReduce job outputs the records with the top K values rather than only the maximum."
The input data set to be used is actually apat63_99.txt file, and the exercise asks for the records with the top K values (CLAIMS) rather than only the maximum. As AttributeMax.py described in listing 4.6 was giving records for maximum claims.

Looping in BizTalk

On an Oracle database I got a customer table with at Id and Name and so, and a number of customerstuff tables all related a key.
With the Oracle WCF adapter in BizTalk a need to create a file with all the customers and there stuff
Like this:
<Root>
<Customers>
<Customer>
<Id>1</Id>
<Name>A</Name>
<Stuff1>
<data>
.
.
</data>
</Stuff1>
.
.
<Stuff6>
<data>
.
.
</data>
</Stuff6>
</Customer>
<Customer>
<Id>2</Id>
<Name>B</Name>
<Stuff1>
.
.
.
</Stuff6>
</Customer>
</Customers>
</Root>
I started out with a select of all the customers, and in Orchestration I loop over them, selecting from each customerstuff table with the key from the current customer getting me all the data ready for the first customer node in the result file.
Question: how do I build the result file? I have to add the current customer/customerstuff data to the result file, then do a new loop while still holding on to the result file, how can I do that in BizTalk ?
This may be possible with custom XSLT, but I am unsure without seeing more detail about the input and output schemas.
If you go with the looping approach, this is going to require 3 messages
Output Message (your eventual output)
Current Output Placeholder Message (same schema as your eventual output)
Customer Stuff (the data you want to Append to output on a given pass through the loop)
and a map that has two messages to one (or some XPATH based manipulation):
For Each Customer
Create "Customer Stuff"
Copy Output Message to Current Output Placeholder
Perform Map that takes Customer Stuff and Current Output Placeholder Message as input and maps to the "Output Message"
Try using something similar to "for xml" in sql server, when you read the data itself using query or stored procedure. In oracle you can return the result set as xml using dbms_xmlgen package:
select dbms_xmlgen.getxml('select * from emp where rownum <= 2') xmlstr from dual;

Add New Varchar2 Field in Oracle SQL Developer [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm new to Oracle. I need to add a varchar2 field to an existing table which is 50 bytes in length.
I right clicked on the table like this:
...Then I arrive at this field:
I do not know what to do here. I was expecting to see a 'type', 'size'and 'units' prompt like in the schema-design-GUI view (where I would enter ~varchar2, 45, and bytes respectively). I don't know what to make of the precisions and scale fields; I thought those were for numbers.
You're adding a column. Give it a name ("Column Name"), a type (select from "Data Type" drop-down), and a length ("Precision"). If it's a NUMBER type, you can give it a scale (place to the right of the decimal). In your specific example, give your column a name, leave data type drop-down at VARCHAR2, and specify 50 for precision.

Cannot create a record in ZIP/postal Codes [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I try to import 90 records from a .txt-file into a table in: Administration > Administration Area > Periodic > Data export/import > Definition Groups
I've made a new Definition Group, set the name and type (Custom) of it and Selected the Default file name.
In the Table setup I deleted all records and selected the table where I want to import the records, Import status = Import.
After clicking on the import-button in the Definition group-window I'm getting error-messages for every record and no data is imported:
ERROR message sais: Cannot create a record in ZIP/postal Codes (CLIAddressZipCode).
ZIP/postal Code: , . The record already exists.
EXAMPLE OF A RECORD:
1440;Les Frèchaux;175557;BRAINE-LE-CHÂTEAU
The 1st field is the zipcode, the 2nd is the street, the 3rd is the ID, the 4th field is the city.
UPDATE:
I will try to add an if-statement: to check if the record already exists, if not the record will be inserted.
Check for unique indexes in table CLIAddressZipCode (this is not a standard table).
This problem arises when your input contain two records which have the same values in the index fields.
The second record will throw the error when inserted saying: The record already exists.
It's probably a related table that it's inserting into and/or a blank '' record at the very beginning/end. CLIAddressZipCode is custom. Perhaps you're inserting into AddressZipCode, and there is code that will insert into CLIAddressZipCode or vice versa and one of those tables contains the duplicate data.
Could the data be concatenated in some way? eg 12345 is concatenated to 1234 which is the same as 1234.

Resources