Link to home
Start Free TrialLog in
Avatar of buru
buru

asked on

How Do You Insert XML Document To Oracle Database Using INSPROC

I am having problem inserting an XML document into an Oracle database. this is what i have:

my $sql = "<?xml version="1.0"?>
<ROWSET><ROW num="1"><USER_ID>999</USER_ID><FIRST_NAME>test</FIRST_NAME><LAST_NAME>test</LAST_NAME></ROW></ROWSET>

eval {
     my $cursor = $dbh->prepare(q{
        BEGIN
            INSPROC('member', '$sql' );
        END;
    });

     $cursor->execute();
   $dbh->commit;
};
$dbh is a handle that has already been defined and working properly.

The problem i have is whenever I run this Perl script I always get a Java error saying that :
Java exception: oracle.xml.sql.OracleXMLSQLException: Start of root element expected.

If I hardcode the XML document string  in the INSPROC call, it works fine. It inserts the data into the table member. It is always when I pass in $sql. It seems to me that it cannot find an XML document when i pass in $sql.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial