Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    12

    Question Unanswered: 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

  2. #2
    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

  3. #3
    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

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •