Creating a PDF Report with Multiple Queries

Purpose

This tutorial shows you how to create a PDF report that contains a table and graph utilizing two report queries.

Time to Complete

Approximately 15 minutes

Topics

This tutorial covers the following topics:

 Overview
 Prerequisites
 Creating a Report Query With Multiple Queries
 Creating a Report Layout Using Oracle BI Publisher Desktop
 Invoking the Report from an Application Page
 Summary

Viewing Screenshots

 Place the cursor over this icon to load and view all the screenshots for this tutorial. (Caution: This action loads all screenshots simultaneously, so response time may be slow depending on your Internet connection.)

Note: Alternatively, you can place the cursor over an individual icon in the following steps to load and view only the screenshot associated with that step. You can hide an individual screenshot by clicking it.

Overview

Beginning with Oracle Application Express 3.1, a Report Query can contain more than one query. This allows you to easily create a PDF file that contains the results of multiple queries. In this tutorial, you will create a Report Query with two queries. The Report Layout consists of a table and a graph in one report layout. When the report is executed, the PDF file will contain two reports in the one document.

Back to Topic List

Prerequisites

Before you perform this tutorial, you should:

1.

Install Oracle Database 11g.

2.

Install Oracle BI Publisher. See document PDF Printing.

3.

Install Oracle BI Publisher Desktop.

4.

Configure Oracle Application Express for Advanced Report Printing. See document PDF Printing.

5.

Download and unzip the apexprnt.zip into your working directory.

6.

Install Microsoft Word. Note that this OBE is only supported on Windows because of this requirement.

7.

Install the Flash Player from Adobe.

8.

Import the Printing Application in Application Builder using the printapp.sql file located in the directory where you unzipped the file in the previous step.

Note: Within your development environment, in order for Oracle BI Publisher Desktop to work, Microsoft Word needs to be installed.  For end users to run the resulting application, the Oracle BI Publisher Desktop is not needed. Just the appropriate application to open the file your application produces is needed; PDF reader, MS Word, MS Excel, etc.

Back to Topic List

Creating a Report Query With Multiple Queries

In this section, you create a Report Query with multiple queries. Perform the following steps:

1.

Enter the following URL to log in to Oracle Application Express (change the <hostname> to localhost, your specific hostname or apex.oracle.com).

http://<hostname>:8080/apex

 

2.

To log in to Oracle Application Express, enter the following details, and click Login.

Workspace: <your workspace name>
Username: <your username>
Password: <your password>

 

3.

On the Workspace home page, click Application Builder .

 

4.

Select Printing Application.

 

5. Click Shared Components.

 

6.

Under Reports, click Report Queries.

 

7.

Click Create.

 

8.

Enter multiquery for the Name and click Next.

 

9.

Click Query Builder to create the query.

 

10.

From the list of queries, select OEHR_EMPLOYEES.

 

11.

Select the check box in front of each of the following columns and click Return.

FIRST_NAME
LAST_NAME
EMAIL
HIRE_DATE
JOB_ID
SALARY

 

12.

Your SQL Query is shown. Click Next.

 

13.

You want to add another query, click Add Query.

 

14.

Click Query Builder again.

multiquery12

 

15.

Select OEHR_DEPARTMENTS and OEHR_EMPLOYEES.

 

16.

To create the join condition, Drag OEHR_DEPARTMENTS.MANAGER_ID over OEHR_EMPLOYEES.EMPLOYEE_ID.

 

17.

Select the check box in front of each of the following columns and click Return.

OEHR_DEPARTMENTS.DEPARTMENT_NAME
OEHR_DEPARTMENTS.MANAGER_ID
OEHR_EMPLOYEES.FIRST_NAME
OEHR_EMPLOYEES.LAST_NAME
OEHR_EMPLOYEES.SALARY

 

18.

To create the query, click Create.

 

19.

The queries have been defined. In the next section of this tutorial, you create the report layout using Oracle BI Publisher Desktop.

 

Back to Topic List

Creating a Report Layout Using Oracle BI Publisher Desktop

In this section, you create a Report Layout based on the multiple queries using Oracle BI Publisher Desktop. Perform the following steps:

1.

From the Source Queries page in the Report Query wizard, click Download.

 

2.

Click Save and save the file as the default name multiquery.xml . Then close the download window.

 

3.

Open Microsoft Word. Select Oracle BI Publisher > Data > Load Sample XML Data...

 

4.

Select multiquery.xml and click Open.

 

5.

The data was loaded successfully. click OK.

 

6.

Select Oracle BI Publisher > Insert > Table/Form...

 

7.

You want all the columns under Rowset1Row to appear in the table. Drag Rowset1 Row to the Template area.

 

8.

Select Drop All Nodes.

 

9.

To create the table, click OK.

 

10.

The table is shown.

 

11.

Resize the columns and add a Title.

 

12.

You now want to create a chart using the second query. Select Oracle BI Publisher > Insert > Chart...

 

13.

Under Rowset2 Row, drag Salary to Values.

 

14.

Drag Department Name to Labels.

 

15.

Select Pie Chart for Type. Scroll down to the Title field and enter Total Salary Percentage by Department. Click OK.

 

16.

The chart is displayed.

 

17.

You need to save your layout as an RTF file. Select File > Save As... Select Rich Text Format (*.rtf) for Save as Type, enter multiquery.rtf for File Name and click Save.

 

18.

Switch back to Application Express and click Next.

 

19.

Click Browse... to select the RTF file you just created. Select the multiquery.rtf file and click Open.

 

20.

Click Next.

 

21.

In order to test your report, you need to first start BI Publisher. Double-click the Start BI Publisher icon on your desktop

 

22.

To test your report, click Test Report.

 

23.

When the dialogue appears, click Open.

 

24.

The table is populated with data, scroll down to see the chart.

 

25.

Close the PDF report. On the Create Shared Query page, click Finish.

 

26.

Your Report Query and Report Layout were created successfully. In the next section, you create a button on a page that invokes the report.

 

Back to Topic List

Invoking the Report from an Application Page

In this section, you invoke the report query from a page in your application. Perform the following steps:

1.

Navigate to your Printing Application page. Click the Home page.

 

2.

Click the Create Button icon.

 

3.

Select the Home region and click Next.

 

4.

Accept the default and click Next.

 

5. Enter Print Report for Button Name and select Download printable report query for Action and click Next.

 

6.

Accept the default and click Next.

 

7.

Select [Top] from the list of quick links or select Top of Region from the drop down list and select Left for Alignment and click Next.

 

8.

Select multiquery for the Report Query and click Create Button.

 

9.

You button was created successfully. Click Run.

 

10.

You may be asked to login to the application. Enter your username and password and click Login.

 

11.

Click Print Report.

 

12.

Click Open to open the PDF report.

 

13.

The report is displayed.

 

Back to Topic List

 

Summary

In this tutorial, you learned how to:

 Create a report query with multiple queries
 Create a report layout using Oracle BI Publisher Desktop
 Invoke a report from an application page

Back to Topic List

 Place the cursor over this icon to hide all screenshots.

Left Curve
Popular Downloads
Right Curve
Untitled Document