19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes 1/33 oracle.com/webfolder/technetwork/tutorials/obe/db/11g/r2/prod/bidw/olap-apex/usingapex4olap.htm Creating Interactive APEX Reports Over OLAP 11g Cubes Purpose In this tutorial, you use Oracle Application Express (APEX) to create an interactive sales analysis report that runs against OLAP 11g data. You learn how to query and create analytic reports of OLAP 11g cubes, including both stored and calculated measures. You also learn how to apply query techniques that leverage unique characteristics of OLAP 11g cubes. Time to Complete: Approximately 60 minutes Topics This tutorial covers the following topics: Overview Scenario Prerequisites Import and Install a Predefined Workspace Create an Application Create an Interactive Sales Analysis Report Format the Interactive Report Add Drilldown Capabilities and Run the Report Add a Report Reset Button More Information Viewing Screenshots Place the cursor over this icon to load and view all the screenshots for this tutorial. (Caution: Because this action loads all screenshots simultaneously, response time may be slow depending on your Internet connection.) Note: Alternatively, you can place the cursor over each individual icon in the following steps to load and view only the screenshot associated with that step. Overview What is APEX? APEX is a Web-based application development and deployment tool integrated with Oracle Database 11g. Using only a Web browser, you can quickly create a reliable, secure, and scalable Web application that can be instantly deployed to thousands of users. APEX combines the ease of use and productivity of a personal database with the availability and scalability of an enterprise database. APEX wizards and built-in features simplify the building of Web applications. You can quickly assemble database- driven applications with little or no programming, in a short span of time. How Do SQL Tools Like APEX Access Oracle OLAP Cubes? The data in an Oracle OLAP cube is made directly accessible to SQL by a set of relational views. These views represent an OLAP cube as a star schema with the following characteristics: - A cube view plays the role of a fact table. - Dimension views and hierarchy views play the role of dimension tables.
33
Embed
Creating Interactive APEX Reports Over OLAP 11g Cubes
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
Creating Interactive APEX Reports Over OLAP 11g Cubes
Purpose
In this tutorial, you use Oracle Application Express (APEX) to create an interactive sales analysis report that runs againstOLAP 11g data.
You learn how to query and create analytic reports of OLAP 11g cubes, including both stored and calculated measures. Youalso learn how to apply query techniques that leverage unique characteristics of OLAP 11g cubes.
Time to Complete:
Approximately 60 minutes
Topics
This tutorial covers the following topics:
Overview
Scenario
Prerequisites
Import and Install a Predefined Workspace
Create an Application
Create an Interactive Sales Analysis Report
Format the Interactive Report
Add Drilldown Capabilities and Run the Report
Add a Report Reset Button
More Information
Viewing Screenshots
Place the cursor over this icon to load and view all the screenshots for this tutorial. (Caution: Because this action
loads all screenshots simultaneously, response time may be slow depending on your Internet connection.)
Note: Alternatively, you can place the cursor over each individual icon in the following steps to load and view only thescreenshot associated with that step.
Overview
What is APEX?
APEX is a Web-based application development and deployment tool integrated with Oracle Database 11g. Using only a Webbrowser, you can quickly create a reliable, secure, and scalable Web application that can be instantly deployed to thousandsof users.
APEX combines the ease of use and productivity of a personal database with the availability and scalability of an enterprisedatabase. APEX wizards and built-in features simplify the building of Web applications. You can quickly assemble database-driven applications with little or no programming, in a short span of time.
How Do SQL Tools Like APEX Access Oracle OLAP Cubes?
The data in an Oracle OLAP cube is made directly accessible to SQL by a set of relational views. These views represent anOLAP cube as a star schema with the following characteristics:
- A cube view plays the role of a fact table.
- Dimension views and hierarchy views play the role of dimension tables.
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
The star design exposed by OLAP cubes is very similar to traditional table-based star models. The dimension views form aconstellation around one or more cube views. However, there are two key differences:
- Fact tables in a star schema store detail data (called leaves), while the cube views reveal many summarylevels.
- Calculations in a cube are simply exposed as columns in the cube view, and the computation for theequations occurs in the OLAP engine.
These differences impact the way you query data. With star queries, you aggregate the data by combining aggregationfunctions (such as sum) and the GROUP BY clause.
With OLAP queries, you simply select the data you want (either stored or calculated) as a column. Selecting aggregate datais easily accomplished using conditions in the "where" clause. Typically, no aggregation function is necessary since thedata has already been summarized by the cube. This enables a single, parameterized cube query to be used to return datafrom any summary level. For example, no changes to the query are required to select sales revenue by month, quarter oryear. This greatly simplifies the ability to "drill anywhere".
For the vast majority of cube-based queries, there are four basic steps:
1. Select measures and dimension attributes.2. Join the cube and dimension views.3. Apply measure and dimension attribute conditions.4. Use “All” filters to leverage summaries for excluded dimension columns.
Combining APEX and Oracle OLAP
APEX provides a flexible environment for the creation of applications on top of any Oracle Database 11g data source.Therefore, you can create compelling, interactive, exploratory reports using APEX against OLAP 11g data using the OLAPcube views.
Since OLAP 11g cube views encapsulate the business rules for your data, it is very simple to select and explore the analyticinformation that you need. When combining OLAP cube views and APEX, you can deliver interactive analysis dashboardsvery easily.
Back to Topic List
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
In this tutorial, you create an interactive, analytic report of OLAP 11g data by performing the following five tasks:
1. Import and install a predefined APEX Workspace. The workspace includes an APEX developer with access to theolaptrain sample schema.
2. Create an application that will contain the report.
3. Create an interactive report that includes highly stylized output.
4. Add formatting to the report.
5. Leverage query parameters to enable data exploration using “drilling” across the dimensions in the report.
Note: OLAP 11g supports the style of drilldown used in this tutorial with any type of hierarchy: level-based, parent-child, skip-level, ragged, and so on.
When you are done, you will have a formatted, interactive sales analysis report that enables users to explore data by drillingdown on products, times, and geographies. The resulting report will look like the following:
Using this report, users:
Can drill down on Geography, Product, and Time to any level of detail
May want to follow the “Product Alert” column when drilling down, since this column indicates that Sales have droppedcompared to last year for at least one of the children of the current product
For example, in the preceding report, Computers’ Sales in 2008 for Africa have improved by 22.4% compared to last year, butthere is an ALERT. Drilling down on Computers will show that there is a problem with sales within the department.
Note: The OLAP data for this tutorial was created using steps found in the Building OLAP11g Cubes tutorial. For informationabout the OLAP data model, and for step-by-step instructions on how to create OLAP 11g cubes, click the link.
Back to Topic List
Prerequisites
Before you perform this tutorial, you should:
1. Install Oracle Database 11g with the OLAP Option (Patch level 11.1.0.7 or higher).
2. Download and install the OLAPTRAIN sample schema and the OLAP 11g data model that is based on the sampleschema. Use the instructions found in Installing the Oracle OLAP 11g Sample Schema.
3. Have access to Oracle Application Express, version 3.1.2 or higher. You can Download and install OracleApplication Express from OTN.
Notes:
On Windows, Application Express runs in shared server mode - even if the database is configured in dedicatedmode.
An Oracle configuration parameter needs to set in order to access OLAP cubes when Oracle Database isconfigured in shared server mode. Otherwise, an error will be generated referencing the inability to load an OLAPAPI sharable library.
Listed below is an example of how to update the configuration parameter when the database is started using anspfile:
a. Login into sqlplus as sysdba. For example:
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
SQL> alter system set "_xsolapi_load_at_process_start"=ALWAYS scope=spfile;
c. Then, stop and restart the database. For example:
SQL> shutdown immediate
. . .
SQL> startup
d.Exit SQL Plus.
4. Save and extract OLAP11g-APEX.zip to a location on the computer that contains APEX. This archive contains twofiles: SALESTRACK_WORKSPACE.sql and apex-olap.sql. The first file is a predefined APEX workspace thatprovides access to the OLAP data. The second file contains a predefined OLAP cube query that you use as part ofthe definition of your interactive report.
5. Have basic knowledge of Oracle Application Express. For more information on APEX, see the following OBEtutorials on Oracle Application Express.
Back to Topic List
Import and Install a Predefined Workspace
In this topic, you log into APEX as the administrator. You then import and install a predefined workspace that contains anAPEX developer. You will also create an APEX schema that provides access to the sample OLAPTRAIN schema.
Follow these steps to create the interactive report:
1. Start your web browser and navigate to the Application Express login page for administrators using the following URLformat:
http://<hostame>:<port#>/apex/apex_admin
Note: The port number is defined by the APEX administrator when APEX is installed.
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
Result: the workspace import and installation is complete:
10.Click the Logout link to log out of the APEX Administration tool.
Back to Topic List
Create an Application
In this topic, you log into APEX as a developer and access the predefined workspace. WIthin the workspace, you define anapplication for your interactive report.
Follow these steps:
1. Start your web browser and navigate to the Application Express login page using the following URL format:
http://<hostame>:<port#>/apex
Note: The port number is defined by the APEX administrator when APEX is installed.
For example:
http://localhost:8080/apex
2. Log in using the following details:
- Workspace: SALESTRACK
- Username: olaptrain
- Password: oracle
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
Result: The new application appears in the Application Builder window.
Back to Topic List
Create an Interactive Sales Analysis Report
Next, you perform two primary tasks to develop the interactive report:
Create three Hidden Items that are used later as part of a parameterized query. The parameters you define will be usedfor setting up dimension “drilling” in a later topic.
For example, a hidden item named P1_PRODUCT will be used as a parameter for drilling down on the Productdimension in the sales query as follows:
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
9. In the Source step, you will use the predefined SQL query that you downloaded earlier (from the Prerequisitessection) as the source for the report region.
Perform the following:
a. Select File > Open File from the browser’s main menu.
b. Open the <download_location>/apex-olap.sql file, that you downloaded previously.
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
Note: This single SELECT statement, explained in the following image, is used to navigate vast regions of theOLAP cube. Notice that the parameter names match the hidden items you created previously.
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
Your report should now look something like the following:
8. Scroll through the report to view the formatting.
9. Save the report as the default.
a. Click the Gear icon and then select Save Report from the menu.
b. Name the report Default Report Settings.
c. Click Apply.
Back to Topic List
Add Drilldown Capabilities and Run the Report
The next task is to enable drilldown capabilities to the report. When users click a Geography, Product or Time value, thedetails for the selected item will replace what was selected. For example, clicking CY2009 displays the calendar quarters forthat year.
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
APEX allows you to specify links for columns on the Report Attributes page. In this case, the link will set the relevantdimension parameter (a.k.a. Hidden Item) to the item the user selected.
Consider the flow for a drilldown on the Time dimension:
User clicks the CY2009 link.
The logic behind the link specifies that the parameter P1_TIME is set to the selected value.
The query is re-executed, whereby the condition:
t.parent = nvl(:P1_TIME, 'ALL_YEARS')
Selects all time values whose parent is ‘CY2009.’ This is the equivalent to selecting the children of ‘CY2009.’
Result: A drilldown has been executed.
Perform the following steps to add drilldown capabilities to the report:
1. Return to the page editor by clicking the Edit Page 1 link at the bottom of the report page.
2. Go to the Report Attributes page by clicking the Interactive Report link in the Regions pane.
3. Add a drilldown link to Geography by performing the following:
a. Click the Edit icon for Geography.
b. Click the Link button above the Column Definition page.
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
c. In the Column Link window, click the [Geography] link to create the Link Text, and then enter 1 in the Pagetext box (that is, the current page number is “1”).
d. Then, use the flashlight tools to select the name value pairs as shown here:
Notes:
- You set the “link” dimension to the current member. This value, as described earlier, will cause thedrilldown on Geography.
- You also set parameters for the Product and Time dimensions as well. By setting these values to the parentcolumn, you are effectively preserving the state of the report (the children of a parent produces the current setof members). This allows browser operations like bookmarking to re-create the report in its drilldown state;these parameters appear in the URL.
e. When you are done, the Column Link window should look like this:
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
7. Once again, click Run at the top of the Page Definition window. The report should look like this:
8. For Africa, click the Computers link for CY2008 (as shown below). This is the row that had excellent percentgrowth in sales, but showed an Alert in the following data.
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes
The resulting report shows the Computer division products that contain underlying alerts:
9. Experiment with the interactive report by clicking on any of the interactive links. With every drill, the OLAP engine re-calculates the data and returns the query results great speed.
This one query enables the user to navigate vast regions of the OLAP cube, providing an interactive, ad-hoc queryand analysis reporting environment.
10. When you are done with the report, click Logout.
Back to Topic List
Add a Report Reset Button
It is often useful to add a reset button to the report. This allows you to reset the report to its original state.
To add a reset button:
1. Click the Application 101 link at the bottom of the login page (as shown below) to return to the Application Builderpage, and then click the Sales Analysis icon to return to the Page Definitions page.
19/04/12 Creating Interactive APEX Reports Over OLAP 11g Cubes