Re: XML Document - Retrieving
I don't have XML Extender installed so I can't check right away but I don't believe there's a straightforward way to accomplish this.
Originally posted by sathyaram_s
DB2 v 7.2 FP 9 and XML Extender on AIX ..
My XML Document is in /tmp/xmldoc :
<product code="PROD1" type="type1">
<product code="PROD2" type="type2">
When I issue ,
select * from table(db2xml.extractvarchars(db2xml.xmlfile('/tmp/xmldoc'),'/products/product/@code')) as z"
How do I get a four column table output as below :
PROD1 type1 Prodcut1 usage1
PROD2 type2 Prodcut2 usage2
Thanks for your replies ...
You could rely on the XML extender processing your xml file in the same order every time it accesses it, and do the following:
- declare four tables similar to
create table t_code (
id integer generated always as identity,
- insert each element (attribute) into its own table:
insert into t_code (value) select returnedvarchar from table(db2xml.extractvarchars(db2xml.xmlfile('/tmp/xmldoc'),'/products/product/@code')) as z;
- then select values from those 4 tables joining them by id
I hope the above makes sense...
On the other hand, if this is something that you'll be doing frequently a better solution would be to create a table with an xml column and side tables for attribute values.
"It does not work" is not a valid problem statement.