DBMS_XMLGEN.GETXML Raises ORA-01008 If The Bind Variable Is NULL, Up To 10.2 (Doc ID 1448994.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Server - Standard Edition - Version 10.1.0.2 to 10.2.0.4 [Release 10.1 to 10.2]
Information in this document applies to any platform.

Symptoms


Generating an xml document using dbms_xmlgen.getxml for a query where a bind variable is set to null raises the errors
ORA-19202: Error occurred in XML processing
ORA-01008: not all variables bound
up to the Oracle Server 10.2.0.4

Example

declare
  xmlCtx integer;
  l_sql_str long := 'select :RUN_ID RUN_ID from dual';
  p_run_id integer;
begin
 xmlCtx := dbms_xmlgen.newContext (l_sql_str);
  dbms_xmlgen.setNullHandling (xmlCtx, dbms_xmlgen.empty_tag);
  dbms_xmlgen.setbindvalue (xmlCtx, 'RUN_ID', p_run_id);

 dbms_output.put_line (dbms_xmlgen.getxml (xmlCtx));
end;
/

declare
*
ERROR at line 1:
ORA-19202: Error occurred in XML processing
ORA-01008: not all variables bound
ORA-06512: at "SYS.DBMS_XMLGEN", line 7
ORA-06512: at "SYS.DBMS_XMLGEN", line 147
ORA-06512: at line 10



It works starting from Oracle Server 11.1 where the output is

<?xml version="1.0"?>
<ROWSET>
<ROW>
<RUN_ID/>
</ROW>
</ROWSET>

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms