Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2013
    Posts
    1

    Question Unanswered: Is it possible to send XML file name to DB2 Stored Procedure ?

    For testing purpose, I have a DB2 Stored Procedure below

    create procedure tmpxml (IN DOC XML)
    Begin
    INSERT INTO tmp_xml (distributorid,sellingind)
    SELECT d, s
    FROM XMLTABLE('$X/Distributor' passing DOC as X
    columns D INTEGER path 'DistributorId',
    S CHAR(5) path 'Person/SellInd') AS x;
    END;


    I know when I try to call it from UNIX using below, it works.
    call tmpxml(XMLPARSE(DOCUMENT '<a>123</a>'))


    However, in my actual environment, I may have an XML file which contains lots of line inside, which I am trying to avoid passing it as above.

    Instead, I try to pass it using file name, like below, but it doesn't seems to work, please help, thanks in advance.

    db2 => call tmpxml(XMLPARSE(DOCUMENT '/export/home/xml/samplefile.xml'))
    SQL16132N XML document contains an invalid document structure.
    SQLSTATE=2200M

    How can I fix this error if I want to pass the file name as parameter ??

    samplefile.xml
    ==============
    <?xml version="1.0" encoding="UTF-8"?>
    <Distributor>
    <DistributorId>12345</DistributorId>
    <Person>
    <SellInd>true</SellInd>
    </Person>
    </Distributor>
    <Distributor>
    <DistributorId>12346</DistributorId>
    <Person>
    <SellInd>true</SellInd>
    </Person>
    </Distributor>
    <Distributor>
    <DistributorId>12347</DistributorId>
    <Person>
    <SellInd>true</SellInd>
    </Person>
    </Distributor>
    Last edited by lwgan; 10-24-13 at 07:27.

  2. #2
    Join Date
    Mar 2003
    Posts
    280
    I havent tried but I would aim for import/load into a staging table or use the UTL_FILE module.
    --
    Lennart

Posting Permissions

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