Developing XML Publisher Report - using Data Source as PL/SQL Stored Procedure

Background: Developing sample XML Publisher Report with Executable Method as 'PL/SQL Stored Procedure' Prerequisite for the below Example: 1. Create a table CREATE TABLE demo_products ( product_code NUMBER, product_name VARCHAR2 (100)); 2. Insert Values INSERT INTO demo_products VALUES (569, 'Oracle Cost Management'); 3. Issue Commit 1. Create a Package Spec & Body with a single Procedure Spec: CREATE OR REPLACE PACKAGE APPS.MY_PACKAGE AS PROCEDURE REPORT (errbuf OUT VARCHAR2, retcode OUT VARCHAR2, p_product_id IN NUMBER); END MY_PACKAGE; / Body: CREATE OR REPLACE PACKAGE BODY APPS.MY_PACKAGE AS PROCEDURE REPORT (errbuf OUT VARCHAR2, retcode OUT VARCHAR2, p_product_id IN NUMBER) IS l_qryCtx DBMS_XMLGEN.ctxHandle; l_query VARCHAR2 (32000); l_length NUMBER (10); l_xmlstr VARCHAR2 (32000); l_offset NUMBER (10) := 32000; l_retrieved NUMBER (10) := 0; l_result CLOB; l_no_rows NUMBER; BEGIN l_query := 'SELECT product_code, product_name FROM demo_products WHERE product_code = ' || p_product_id;

l_retrieved := l_retrieved + l_offset. -. FND_FILE.l_qryCtx := DBMS_XMLGEN. DBMS_XMLGEN. ELSE SELECT SUBSTR (l_result. IF (l_length . END LOOP. fnd_file.setRowTag (l_qryCtx. 'Length= ' || l_length). LOOP EXIT WHEN l_length = l_retrieved.LOG. Description & also .LOG. / 2. l_length := NVL (DBMS_LOB. END IF.put_line (').newContext (l_query). l_xmlstr).put_line (fnd_file. 'No of rows processed= ' || l_no_rows).set rowset tag to PRODUCTS and row tag to PRO_DETAILS DBMS_XMLGEN.setRowSetTag ( get the result l_result := DBMS_XMLGEN.output. Short Name. fnd_file.put_line (fnd_file. l_offset) INTO l_xmlstr FROM DUAL.put_line (FND_FILE. Define Executable Navigation: Application Developer > Concurrent > Executable Provide Executable. END MY_PACKAGE.LOG.closeContext (l_qryCtx). 'PRO_DETAILS'). SQLERRM). END REPORT.l_retrieved) < 32000 THEN SELECT SUBSTR (l_result. 'Error in procedure MY_PACKAGE. 'PRODUCTS').getXML (l_qryCtx). raise_application_error (-20001.PUT_LINE (FND_FILE. l_retrieved := l_length. FND_FILE.getlength (l_result). l_retrieved + 1) INTO l_xmlstr FROM DUAL. -. 0). EXCEPTION WHEN OTHERS THEN FND_FILE. DBMS_XMLGEN.GETNUMROWSPROCESSED (l_qryCtx). l_no_rows := DBMS_XMLGEN. l_retrieved + 1.output. l_xmlstr). Application.

Register Template with the XML Publisher Navigation: XML Publisher Administrator -> Templates -> Create Template 6.Associate Concurrent Program to the Request Group. Create Data Definition Navigation: XML Publisher Administrator -> Data Definitions -> Create Data Definition The code should be exactly same as concurrent program short name. 5.REPORT 3.Define a Parameter p_product_id .Output Format should be XML . Define Concurrent Program Navigation: Application Developer > Concurrent > Program Provide Program. Application. 4. Run the Concurrent Program to see the output . Create Template.Execution Method: PL/SQL Stored Procedure Execution File Name: MY_PACKAGE.Executable Name as defined in the above step . Short name. Description & also .

Sign up to vote on this title
UsefulNot useful