DEVELOPER: Browser-BasedAdvanced Interactive ReportingBy David PeakeExtend interactive reports with Oracle Application Express. Oracle Application Express has included interactive reporting capabilities since Release 3.1. With interactive reporting, end users can modify their own data layouts directly in the Web application. Each user can rearrange a report’s data and save multiple layouts for later reference without having an impact on other users. A previous column, “Building Interactive Reports” ( Oracle Magazine, March/April 2008), explains how to build these reports. This column will take you through some of the more advanced techniques you can employ with Oracle Application Express interactive reports. We will use the sample application that was built by default when your workspace was created. To begin, confirm that the sample application is installed: 1. Log in to Oracle Application Express. (If you do not have an instance, you can request a workspace at apex.oracle.com.) Setting Parameters for Interactive ReportsIf, as a developer of a classic report, you wanted your end users to be able to focus a report by using Search fields, you would need to define a search region, create items, add a button, and modify the underlying SQL to use these search items. With Oracle Application Express interactive reporting, you need to use different techniques, such as setting parameters in the URL to programmatically define report filters. Removing the search bar. As a developer, you have the ability to include or exclude any of the Oracle Application Express Actions menu items (available via the gear icon) and to include or exclude the search bar altogether. However, if you remove the Reset function, your users will not have the ability to easily reset their reports after they have performed customizations. To provide reset capability to your users in this example, you will add a Reset button before you remove the search bar. To reset an interactive report in a link, use the string RIR in the clear cache section of a URL. This is equivalent to the end user’s choosing the Reset option from the interactive report Actions menu on the target page. The report returns to the default report settings specified by the developer or saved by the user. For this example, we will create the Reset button and remove the search bar from the Products page within the sample application: 1. From the Application Builder, click Sample Application. Now edit the Reset button to include the RIR string: 8. Within Buttons, click the Reset link. Now remove the search bar: 11. Within Regions, click the Interactive Report link. Now when you run the application, the search bar will be removed and there will be a Reset button. If you or your end users change the interactive report by using the column actions, clicking the Reset button will return the report back to its original layout. Defining a declarative filter. Within Oracle Application Express interactive reports, an end user can define a column filter by simply clicking a column heading and choosing the appropriate value. Alternatively, a user can define a more complex filter from the Actions menu. A filter is defined as a string in the following format:
IR<operator>_<target column alias> where the valid operators are
To demonstrate how these filters can be used, you will create links from the Orders report on the home page to the customer interactive report: 1. From the Application Builder, click Sample Application.
o.order_id,
to
c.customer_id, o.order_id,
5. Click Apply Changes ; click Apply Changes.
The Orders report on the home page now includes drill-down links to each customer (under Customer Name) and to the customer interactive report. Another example of declarative filters is available in the hosted APEX Conference Sessions (http://apex.oracle.com/pls/otn/f?p=59652:1:0) application. For example, you may want to show only 2008 sessions for “OUG” conferences. To do this, you would enter the following URL:
http://apex.oracle.com/pls/otn/f?p=59652:1:0:::: IRGTE_YEAR, IRLT_YEAR, IRC_CONFERENCE:2008,2009,OUG The URL will get records in which the year is greater than or equal to 2008 (IRGTE_YEAR), the year is less than 2009 (IRLT_YEAR), and the conference contains “OUG” (IRC_CONFERENCE). Creating derived columns. Adding SQL derivations to your region source for interactive reports can be a very effective way to show additional information. In the following example, you are going to create a derived column that checks for order totals that exceed the customer’s credit limit, and within the report, you are going to highlight these records: 1. From the Application Builder, click Sample Application. Figure 1 shows the interactive report with the derived column checking for order totals over a customer’s credit limit and the Over Limit columns highlighted.
David Peake (david.peake@oracle.com) is a principal product manager in Oracle’s Server Technologies division. He has been with Oracle since 1993. |
