0% found this document useful (0 votes)
9 views

BI Publisher

The document details the steps to generate an XML file from a database using a PL/SQL procedure. It describes creating a cursor to query the necessary data, declaring a record to hold the results, looping through the cursor to output each record to XML tags, and closing the cursor. It also provides instructions for configuring the browser to properly display the generated XML file.

Uploaded by

kapilraghav1221
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

BI Publisher

The document details the steps to generate an XML file from a database using a PL/SQL procedure. It describes creating a cursor to query the necessary data, declaring a record to hold the results, looping through the cursor to output each record to XML tags, and closing the cursor. It also provides instructions for configuring the browser to properly display the generated XML file.

Uploaded by

kapilraghav1221
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

BI Publisher (Half part)

Procedure to generate XML file

We want to generate a XML File as shown below

<?xml version="1.0"?>

<EmployeeRoot>

<EMPLOYEE>

<PERSON_ID>194</PERSON_ID>

<FULL_NAME>Colby, Ms. Nelda</FULL_NAME>

<DATE_OF_BIRTH>05-SEP-27</DATE_OF_BIRTH>

</EMPLOYEE>

<EMPLOYEE>

<PERSON_ID>195</PERSON_ID>

<FULL_NAME>Summers, Ms. Sandra</FULL_NAME>

<DATE_OF_BIRTH>18-OCT-63</DATE_OF_BIRTH>

</EMPLOYEE>

<EMPLOYEE>

<PERSON_ID>196</PERSON_ID>

<FULL_NAME>Jensen, Brenda</FULL_NAME>

<DATE_OF_BIRTH>19-OCT-54</DATE_OF_BIRTH>

</EMPLOYEE>

<EMPLOYEE>

<PERSON_ID>197</PERSON_ID>

<FULL_NAME>Jensen, Jonathan</FULL_NAME>

<DATE_OF_BIRTH>24-APR-70</DATE_OF_BIRTH>

</EMPLOYEE>

<EMPLOYEE>

<PERSON_ID>198</PERSON_ID>

<FULL_NAME>Slauder, Ms. Lisa</FULL_NAME>

<DATE_OF_BIRTH>23-JAN-72</DATE_OF_BIRTH>
</EMPLOYEE>

</EmployeeRoot>

-- Select statement to generate the data

select person_id, full_name, date_of_birth

from PER_ALL_PEOPLE_F

where person_id between 194 and 198;

-- Creating a procedure to generate XML

drop procedure XXCTS_EMPLOYEE;

create or replace procedure XXCTS_EMPLOYEE

is

cursor EMP_CUR

is

SELECT PERSON_ID, FULL_NAME, DATE_OF_BIRTH

from PER_ALL_PEOPLE_F

WHERE PERSON_ID BETWEEN 194 AND 198;

-- Declare a Record

-- Record is a collection of fields

-- Record can be declared on the basis of a table / cursor

-- Declaring a Record based on a Cursor

EMP_REC EMP_CUR%ROWTYPE;

-- emp_rec is the name of the record

-- emp_rec will hold person_id, full_name and date_of_birth

BEGIN

OPEN EMP_CUR; -- It will the execute the query , active set gets created and

-- it will point to the row above the first row


DBMS_OUTPUT.PUT_LINE('<?xml version="1.0"?>');

DBMS_OUTPUT.PUT_LINE('<EmployeeRoot>');

LOOP

-- Fetch fetches one row from the Active Set and stores

-- it into the record

FETCH EMP_CUR

INTO EMP_REC;

-- STOP WHEN THE Records present in the Active Set are processed.

EXIT WHEN EMP_CUR%NOTFOUND;

DBMS_OUTPUT.PUT_LINE('<EMPLOYEE>');

DBMS_OUTPUT.PUT_LINE('<PERSON_ID>' || EMP_REC.PERSON_ID || '</PERSON_ID>');

DBMS_OUTPUT.PUT_LINE('<FULL_NAME>' || EMP_REC.FULL_NAME || '</FULL_NAME>');

DBMS_OUTPUT.PUT_LINE('<DATE_OF_BIRTH>'|| EMP_REC.DATE_OF_BIRTH ||
'</DATE_OF_BIRTH>');

DBMS_OUTPUT.PUT_LINE('</EMPLOYEE>');

END LOOP;

DBMS_OUTPUT.PUT_LINE('</EmployeeRoot>');

CLOSE EMP_CUR; -- Memory is released.

end;

-- To locate the Errors using USER_ERRORS data dictionary

SELECT *

FROM USER_ERRORS

where name =upper('XXCTS_EMPLOYEE');

exec XXCTS_EMPLOYEE;

Internet Explorer Settings for XML file to be displayed


Additionally, follow these steps:
1. Open Internet Explorer.
2. Click “Tools” and “Internet Options.”
3. Click the “Advanced” tab.
4. Scroll down to “Security.”
5. Select and check "Allow active content to run in files on My Computer."
6. Click “Apply” and click “OK.”
7. Restart Internet Explorer.

Ensure that the Enable native XMLHTTP support is checked in Internet Explorer > Internet Options >
Advanced > Security

You might also like