trebems
asked on
Parsing error in pl/sql from xml created in .net
Hi all!
I'm creating a pretty basic XML file in .NET and inserting it into a CLOB field in an Oracle DB - then am using a stored procedure to parse the XML and read it's contents. I keep getting the foloowing errors:
ORA-31011: XML parsing failed
0RA-19202: Error occurred in XML processing
LPX-00217: Invalid character 0 (U+0000)
If I edit the CLOB (using a pl/sql developers tool) and delete a character and then replace the same character (doesn't matter which character I edit) - then it parses just fine.
If there are NULL characters in the CLOB - how do I remove them?
Please help!
Thanks!
I'm creating a pretty basic XML file in .NET and inserting it into a CLOB field in an Oracle DB - then am using a stored procedure to parse the XML and read it's contents. I keep getting the foloowing errors:
ORA-31011: XML parsing failed
0RA-19202: Error occurred in XML processing
LPX-00217: Invalid character 0 (U+0000)
If I edit the CLOB (using a pl/sql developers tool) and delete a character and then replace the same character (doesn't matter which character I edit) - then it parses just fine.
If there are NULL characters in the CLOB - how do I remove them?
Please help!
Thanks!
Here's the XML that's created in the .NET app:
<?xml version="1.0" encoding="UTF-8"?>
<PARAMS type="Chart">
<CHART num="1" typeid="103" name="ATTRIBUTE_SUM" display="ATTRIBUTE SUMMARY">
<CLTID>496</CLTID>
<qct_id>2404</qct_id>
<tier5_yn>N</tier5_yn>
</CHART>
</PARAMS>
Here's the way it's inserted into the DB:
while (oReader.Peek() >= 0)
{
char[] sChunk = new char[1000];
oReader.Read(sChunk, 0, sChunk.Length);
string sContentChunk = "";
for (int nCount = 0; nCount <= sChunk.Length - 1; nCount++)
{
if (sChunk[nCount] != null)
sContentChunk = sContentChunk + sChunk[nCount];
}
if (sContentChunk.Length > 0)
{
oraCommand.Parameters.Add("P_id",
OracleType.Int32).Value = RptId;
oraCommand.Parameters.Add("P_buffer",
OracleType.VarChar).Value = sContentChunk;
oraCommand.Parameters.Add("P_buffer_length",
OracleType.Int32).Value = sContentChunk.Length;
oraCommand.Parameters.Add("p_table_name",
OracleType.VarChar).Value = TableName;
}
oraCommand.ExecuteNonQuery();
oraCommand.Parameters.Clear();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I guess I should have looked a little harder. The parameter being passed to Oracle was a string: sContentChunk not sChunk.
I think the final read "oReader.Read(sChunk, 0, sChunk.Length);" was picking up the ending terminator and adding it. You might be able to leave the code as-was and just trim off the last character (if it is a '\0').
I think the final read "oReader.Read(sChunk, 0, sChunk.Length);" was picking up the ending terminator and adding it. You might be able to leave the code as-was and just trim off the last character (if it is a '\0').
ASKER
I have it working now chunking through the string - so, I think I will leave well enough alone - thanks again!
ASKER
Thanks!