Skip Headers
Oracle® Database Express Edition 2 Day Plus Application Express Developer Guide
Release 2.1

Part Number B25310-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

3 How to Create a Drill Down Report

A drill down report is a type of report that displays summary data with links to related detail data in a second report.

This tutorial describes how to create a report on the DEMO_ORDERS table with links to drill down detail data in the DEMO_ORDER_ITEMS table. Both tables are installed with the demonstration application, Sample Application.

This section contains the following topics:

About Sample Application

Application Builder installs with a number of demonstration applications. In this exercise you create a drilldown report using the tables that install with the demonstration application, Sample Application.

To see if Sample Application is installed:

  1. Log in to the Database Home Page using your database username and password.

  2. Click the down arrow on the right side of the Application Builder icon.

  3. From the menu, select Demonstrations.

    The Demonstration Applications page appears, displaying links to demonstration applications.

  4. Locate Sample Application and check the Status column:

    1. If the Status column displays Installed, return to the Database Home Page.

    2. If the Status column displays Not Installed, select Install in the Action column. Follow the on-screen instructions.

Creating a New Application

First, create a new application.

To create an application:

  1. On the Database Home Page, click the Application Builder icon.

    The Application Builder home page appears.

  2. Click Create.

  3. Select Create Application and click Next.

  4. Specify the page name.

    1. For Name, enter Drilldown Reports.

    2. For Application, accept the default.

    3. For Create Application, select From scratch.

    4. For Schema, accept the default.

    5. Click Next.

      Next, you need to add pages. You have the option of adding a blank page, a report, a form, a tabular form, or a report and form. For this exercise, you add two blank pages.

  5. Add the first blank page:

    1. Under Select Page Type, select Blank as shown in Figure 3-1.

    2. In Page Name, enter Orders.

    3. Click Add Page.

  6. Add the second blank page:

    1. Under Select Page Type, select Blank.

    2. In Page Name, enter Order Items.

    3. Click Add Page.

    The two new pages appear at the top of the page.

  7. Click Next.

  8. For Tabs, accept the default, One Level of Tabs, and click Next.

  9. For Copy Shared Components from Another Application, accept the default, No, and click Next.

  10. For Attributes, accept the defaults for Authentication Scheme, Language, and User Language Preference Derived From and click Next.

  11. For User Interface, select Theme 2 and click Next.

  12. Review your selections and click Create.

    The Application home page appears. Note your application contains three pages:

    • 1 - Orders

    • 2 - Order Items

    • 101 - Login

Creating Reports for DEMO_ORDERS and DEMO_ORDER_ITEMS

Next, you need to create reports for the DEMO_ORDERS and the DEMO_ORDER_ITEMS tables.

Topics in this section include:

Create a Report for DEMO_ORDERS

To create a report on the DEMO_ORDERS table:

  1. On the Application home page, click Create Page.

  2. Select the page type Report and click Next.

  3. Select Wizard Report and click Next.

  4. For Page Attributes:

    1. For Page, select 1 Orders.

    2. In Page Title and Region Title, enter Orders.

    3. For Region Template, accept the default.

    4. Click Next.

  5. For Tabs, accept the default, Do not use tabs, and click Next.

  6. For Tables and Columns:

    1. For Table/View Owner, select the default.

    2. For Table/View, select DEMO_ORDERS.

      The columns in the DEMO_ORDERS table appear.

    3. From the Available Columns list, press CTRL and move the following columns to the Displayed Columns list as shown in Figure 3-2:

      ORDER_ID, ORDER_TOTAL, ORDER_TIMESTAMP
      
      

      Figure 3-2 Selected Columns

      Description of Figure 3-2 follows
      Description of "Figure 3-2 Selected Columns"

      Next, create a join with the DEMO_CUSTOMERS table to display the customer name. First, select a new table.

    4. From the Table/View list, select DEMO_CUSTOMERS.

      The columns in the DEMO_CUSTOMERS table appear.

    5. From the Available Columns list, select CUST_LAST_NAME and move it to the Display Columns list.

    6. Click Next.

  7. For Join Conditions, accept the join by clicking Next.

  8. For Report Options, accept the defaults and click Next. Click Create Report Page.

  9. Run the page by clicking the Run Page icon. If prompted for a user name and password, enter your database user account credentials.

    As shown in Figure 3-3, a report on the DEMO_ORDERS table appears.

    Figure 3-3 Report on DEMO_ORDERS Table

    Description of Figure 3-3 follows
    Description of "Figure 3-3 Report on DEMO_ORDERS Table"

  10. Click Edit Application on the Developer toolbar to return to Application Builder.

    The Application home page appears.

Create a Report for DEMO_ORDER_ITEMS

To create a report on the DEMO_ORDER_ITEMS table:

  1. On the Application home page, click Create Page.

  2. For Page, select Report and click Next.

  3. On Create Page, select Wizard Report and click Next.

  4. For Page Attributes:

    1. For Page, select 2 Order Items.

    2. In Page Title and Region Title, enter Order Items.

    3. For Region Template, accept the default.

    4. Click Next.

  5. For Tables and Columns:

    1. For Table/View Owner, accept the default.

    2. For Table/View, select DEMO_ORDER_ITEMS.

      The columns in the DEMO_ORDER_ITEMS table appear.

    3. From the Available Columns list, press CTRL and move the following columns to the Displayed Columns list:

      ORDER_ITEM_ID, ORDER_ID, UNIT_PRICE, QUANTITY
      
      

      Next, create a join with the DEMO_PRODUCT_INFO table to display the product name.

    4. For Show Only Related Tables, select No.

      Then, select a new table.

    5. From the Table/View list, select DEMO_PRODUCT_INFO.

      The columns in the DEMO_PRODUCT_INFO table appear.

    6. From the Available Columns list, select PRODUCT_NAME and move it to the Display Columns list.

    7. Click Next.

  6. For Join Conditions:

    1. Under the first Column, select DEMO_ORDER_ITEMS.PRODUCT_ID.

    2. Under the second Column, select DEMO_PRODUCT_INFO.PRODUCT_ID.

    3. Click Next.

  7. For Report Options, accept the defaults and click Next. Click Create Report Page.

  8. Click Run Page.

    As shown in Figure 3-4, a report on the DEMO_ORDER_ITEMS table appears.

    Figure 3-4 Report on DEMO_ORDER_ITEMS Table

    Description of Figure 3-4 follows
    Description of "Figure 3-4 Report on DEMO_ORDER_ITEMS Table"

Customizing the DEMO_ORDER_ITEMS Report

Next, you need to customize the Order Items page. In this exercise, you add an item to hold the value of the ORDER_ID, add a condition that constrains the report by the value of ORDER_ID item, and modify the Region Title to note which order is being viewed.

Topics in this section include:

Add an Item to Hold the Value of ORDER_ID

To create an item to hold the value of ORDER_ID:

  1. Navigate to the Page Definition of page 2. Click Edit Page 2 on the Developer toolbar.

    The Page Definition appears.

  2. Under Items, click the Create icon as shown in Figure 3-5.

  3. For Item Type, select Hidden and click Next.

  4. For Display Position and Name:

    1. In Item Name, enter P2_ORDER_ID.

    2. In Sequence, accept the default.

    3. For Region, select Order Items.

    4. Click Next.

  5. Click Create Item.

Add a Condition

To add a condition to the DEMO_ORDER_ITEMS report:

  1. Under Regions, select Order Items as shown in Figure 3-6.

  2. Select the Query Definition tab.

  3. Click Modify Join Conditions.

  4. On the Modify Join Conditions page:

    1. For first Column, select DEMO_ORDER_ITEMS.ORDER_ID. Note that you may need to click Search to view available columns.

    2. Enter the following condition in the second Column field:

      = :P2_ORDER_ID
      
      
  5. Click Apply Changes.

Modify the Region Title

To modify the region title of the DEMO_ORDER_ITEMS report:

  1. Under Regions, click Order Items.

  2. In Title replace the existing text with the following:

    Order Items for Order # &P2_ORDER_ID.
    
    
  3. Click Apply Changes.

Linking the DEMO_ORDERS Report to the DEMO_ORDER_ITEMS Report

Lastly, you link the DEMO_ORDERS report to the DEMO_ORDER_ITEMS report. To accomplish this, you edit the attributes of the ORDER_ID column on the DEMO_ORDERS report and create a link. The link will populate the P2_ORDER_ID hidden item on page 2 with the clicked ORDER_ID.

To create a link from the ORDER_ID column on the Orders report to the Order Items report:

  1. Navigate to the Page Definition of page 1, Orders. On the Page Definition, enter 1 in the Page field and click Go.

  2. Under Regions, select Orders.

  3. Click the Report Attributes tab.

  4. Click the Edit icon adjacent to ORDER_ID.

  5. Scroll down to Column Link.

    1. In the Page field, select 2 Order Items.

      Next, populate the P2_ORDER_ID hidden item on page 2 with the clicked ORDER_ID.

    2. From Item 1 Name, select P2_ORDER_ID.

    3. From Item 1 Value, select #ORDER_ID#.

    4. For Link Text, select #ORDER_ID#.

    Your Column Link attributes should resemble Figure 3-7.

    Figure 3-7 Column Link Attributes for the Order Id column

    Description of Figure 3-7 follows
    Description of "Figure 3-7 Column Link Attributes for the Order Id column"

  6. Scroll back to the top of the page and click Apply Changes.

  7. Click the Run Page icon in the upper right corner of the page.

    As shown in Figure 3-8, you can link to page 2 by clicking on an Order Id.

    Figure 3-8 DEMO_ORDERS Report with LInk to Page 2

    Description of Figure 3-8 follows
    Description of "Figure 3-8 DEMO_ORDERS Report with LInk to Page 2"