Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Parsing error in pl/sql from xml created in .net

Posted on 2010-01-08
4
Medium Priority
?
1,283 Views
Last Modified: 2013-12-18
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!
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();
   }
 }

Open in new window

0
Comment
Question by:trebems
  • 2
  • 2
4 Comments
 
LVL 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 26212298
Even though this link is for Java I think it's the same issue.

The ending string terminator:
http://forums.oracle.com/forums/thread.jspa?threadID=477449


Any specific reason you're using a character array instead of a string?
0
 

Author Comment

by:trebems
ID: 26212914
I don't know why a character array was being used - I inheirited this code :)  But I changed it over to 'chunk' through a string instead - and it seems to be working.  I'll keep testing with larger XML's.

Thanks!
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 26213031
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').
0
 

Author Comment

by:trebems
ID: 26213429
I have it working now chunking through the string - so, I think I will leave well enough alone - thanks again!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to recover a database from a user managed backup
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question