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_NA ME><LAST_N AME>test</ LAST_NAME> </ROW></RO WSET>
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.OracleXMLSQ LException : 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.
my $sql = "<?xml version="1.0"?>
<ROWSET><ROW num="1"><USER_ID>999</USER
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.OracleXMLSQ
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.