Skip to Main Content
  • Questions
  • ORA-31011: XML parsing failed ORA-06512: at "SYS.DBMS_XMLGEN", line 176

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Sharada.

Asked: September 14, 2015 - 8:40 pm UTC

Last updated: September 18, 2015 - 3:57 am UTC

Version: Oracle 10g

Viewed 10K+ times! This question is

You Asked

Query:
select table_name,column_name

from (select rownum,table_name, regexp_substr(dbms_xmlgen.getxml('select * from "'||table_name||'"'),'<[^>]*>&string</[^<]*>') column_name from user_tables)

where length(column_name)!=0;

Error:
ORA-31011: XML parsing failed
ORA-06512: at "SYS.DBMS_XMLGEN", line 176
ORA-06512: at line 1
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid.

and Connor said...

Most likely one of your tables contains a data type, or data that cannot be readily converted into XML by DBMS_XMLGEN.

Try setting arraysize to 1, or the following:

SQL> set serverout on
SQL> declare
  2    cursor c is
  3     select rownum,
  4            table_name,
  5              dbms_xmlgen.getxml('select * from "'||table_name||'"') column_name
  6     from user_tables ;
  7    r c%rowtype;
  8  begin
  9    open c;
 10    loop
 11      fetch c into r;
 12      exit when c%notfound;
 13      dbms_output.put_line(r.table_name);
 14    end loop;
 15  end;
 16  /
DEPT
EMP

PL/SQL procedure successfully completed.


and see which particular table is causing you problems. Then work from there

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Useful response

Sharada Sahoo, September 15, 2015 - 2:35 pm UTC

The response was clear as the person understood my question.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library