If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 v8.1 querying an XML field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-09-05, 06:22
stenx stenx is offline
Registered User
 
Join Date: Dec 2003
Posts: 12
Question DB2 v8.1 querying an XML field

Hi,

I have an XML document store in a LONGVARCHAR field.
I wanto to know, if is possible,
how to obtain via SQL
a field value/attribute of the XML document.

I hope in an answer soon as possible.

Thank you
Reply With Quote
  #2 (permalink)  
Old 11-09-05, 06:30
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
xml query

All is possible.. just ..
I think the field has to be of datatype xmlvarchar and not varchar
in that case a dtd can be stored in the enabled database and a query can be executed against this xml field
If this is not possible : you can export the xml document to a file with
xmlvarchartofile function. After the export, you can define nicknames on these files, if information integrator non-relational is installed.
this can be done on individual files or against all files in a specific location.
we have tested these scenario. if needed, I can ship you a doc, describing this in detail.. (just let me know)
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
Reply With Quote
  #3 (permalink)  
Old 11-09-05, 06:45
stenx stenx is offline
Registered User
 
Join Date: Dec 2003
Posts: 12
Smile xml query...

Thanks for your speed!

But I see an article on internet (http://www.devx.com/getHelpOn/Article/11004/0/page/3),
and seem that there's the possibility
(using appropriate functions)
to querying an XML field via SQL.
In the specific case he monstrate how
to update a field of an XML document store in a DB field,
using this sintax:

UPDATE sales_tab
SET order = Update(order, '/Order/Customer/Name', 'Customer X')
WHERE sales_person = 'Salesperson Y'

Do you know this?
But my goal is querying and not modify the field
and so I ask if there's the possibility to do this

Thanks
Reply With Quote
  #4 (permalink)  
Old 11-09-05, 11:23
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
xml

yes : this can be done but
Update(order, '/Order/Customer/Name'
is based on dtd description /Order/Customer/Name being the definition in hierarchy for this field
select I have not seen if you do not create side tables and shred the xml document into columns of side table
this (shredding) is also a possibility.
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On