How to generate XML report through PL/SQL Code

First Create procedure or package in Database.

See below sample code

Create or replace procedure xx_test_pro_rep(errfbuff out varchar2,retcode out varchar2)
IS
CURSOR data_cur
IS
SELECT empno, ename, job, hiredate, sal
FROM emp;

output_row data_cur%ROWTYPE;
BEGIN
DBMS_OUTPUT.put_line
(”);
fnd_file.put_line
(fnd_file.output,

);
DBMS_OUTPUT.put_line (”);
fnd_file.put_line (fnd_file.output, ”);


OPEN data_cur;

LOOP

FETCH data_cur
INTO output_row;

EXIT WHEN data_cur%NOTFOUND;

DBMS_OUTPUT.put_line (”);
fnd_file.put_line (fnd_file.output, ”);

DBMS_OUTPUT.put_line ( ”
|| DBMS_XMLGEN.CONVERT (output_row.empno)
|| ”
);
fnd_file.put_line (fnd_file.output,

|| DBMS_XMLGEN.CONVERT (output_row.empno)
|| ”
);

DBMS_OUTPUT.put_line ( ”
|| DBMS_XMLGEN.CONVERT (output_row.ename)
|| ”
);
fnd_file.put_line (fnd_file.output,

|| DBMS_XMLGEN.CONVERT (output_row.ename)
|| ”
);

DBMS_OUTPUT.put_line ( ”
|| DBMS_XMLGEN.CONVERT (output_row.job)
|| ”
);
fnd_file.put_line (fnd_file.output,

|| DBMS_XMLGEN.CONVERT (output_row.job)
|| ”
);

DBMS_OUTPUT.put_line ( ”
|| DBMS_XMLGEN.CONVERT (output_row.hiredate)
|| ”
);
fnd_file.put_line (fnd_file.output,

|| DBMS_XMLGEN.CONVERT (output_row.hiredate)
|| ”
);

DBMS_OUTPUT.put_line ( ”
|| DBMS_XMLGEN.CONVERT (output_row.sal)
|| ”
);
fnd_file.put_line (fnd_file.output,

|| DBMS_XMLGEN.CONVERT (output_row.sal)
|| ”
);

DBMS_OUTPUT.put_line (”);
fnd_file.put_line (fnd_file.output, ”);

END LOOP;

CLOSE data_cur;


DBMS_OUTPUT.put_line (”);
fnd_file.put_line (fnd_file.output, ”);

END xx_test_pro_rep;

 

After that create executable and Concurrent program.

In concurrent program output format is “XML”.

Add CP to responsibility and run program from SRS window.

See output file of that program.

 

 

Thanks

Sajal Agarwal

Advertisements