ORA-31011: XML parsing failed while calling srw.run_report

ORA-31011: XML parsing failed while calling srw.run_report from database

Below is a sample report calling block I copied from Oracle Forums. There was a mistake in the block which was causing the error ORA-31011: XML parsing failed. The solution is simple. the GATEWAY parameter had a 'question mark' at the end of the link.

If you see the output generated by srw.start_debugging, the URL framing would be listed there:
http://192.168.50.53:7778/reports/rwservlet?&SERVER=rep_dev&report=rep_name&userid=user/pass@sid&destype=file&desformat=pdf&destination=/u01/&distribute=yes

If you notice closely there is a & added before SERVER parameter. This is due to the presence of the ? SRW.ADD_PARAMETER of GATEWAY.

If you remove the ? from the last of link the report will be invoked.

DECLARE
v_paramlist srw_paramlist;
v_jobident srw.job_ident;
v_status srw.status_record; 
BEGIN
srw.start_debugging;
v_paramlist := srw_paramlist(srw_parameter('', ''));
srw.add_parameter(v_paramlist, 'GATEWAY', 'http://192.168.50.53:7778/reports/rwservlet?');
srw.add_parameter(v_paramlist, 'SERVER', 'rep_dev');
srw.add_parameter(v_paramlist, 'REPORT', 'rep_name'); --path to where report is
srw.add_parameter(v_paramlist, 'USERID', 'user/pass@sid');
srw.add_parameter(v_paramlist, 'DESTYPE', 'FILE');
srw.add_parameter(v_paramlist, 'DESFORMAT', 'PDF');
--srw.add_parameter(v_paramlist, 'DESTINATION', '/u01/');--path to where xml file
srw.add_parameter(v_paramlist, 'DESTINATION', '/u01/distribution.xml');--path to where xml file
srw.add_parameter(v_paramlist, 'DISTRIBUTE' , 'YES');
v_jobident := srw.run_report(v_paramlist);
v_status := srw.report_status(v_jobident);
srw.stop_debugging;
END;

Uploading documents - table name configuration


Oracle's Web Toolkit (HTP/HTF) supports creating webpages with full control. I have been using them for my official project and we have built a framework associated with a style sheet we have created.

Among other things it supports uploading files by user. Using the HTML INPUT type="file" we can position the file selection dialog.

The form needs to be open with multipart/form-data.

For the first time if you are using this functionality you may have to configure the table name where Oracle populates the file in a BLOB column. The configuration is part of DAD, placed in Database server within /dbfolder/Apache/modplsql/conf/dads.conf file. "dbfolder" is where you have installed the database.

In the Location tag specify a table for the attribute
     PlsqlDocumentTablename MYDOCUMENTS

A sample document table can consist of the following:

CREATE TABLE [table_name] (
  NAME VARCHAR2(256) UNIQUE NOT NULL,
  MIME_TYPE VARCHAR2(128),
  DOC_SIZE NUMBER,
  DAD_CHARSET VARCHAR2(128),
  LAST_UPDATED DATE,
  CONTENT_TYPE VARCHAR2(128),
  [content_column_name] [content_column_type]
  [ , [content_column_name] [content_column_type]]
);

Oracle then automatically uploads your document to this table.

Check mod_plsql User's Guide for more information on this. This is a mini-tip which I want to share for those who may be looking for the information.