Skip Headers

Oracle® OLAP Reference
10g Release 1 (10.1)

Part Number B10334-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

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

22 DBMS_AW_UTILITIES

The DBMS_AW_UTILITIES package contains procedures for managing custom measures in analytic workspaces.


See Also:


This chapter contains the following topics:

22.1 About Custom Measures

You can use the DBMS_AW_UTILITIES package to define custom measures within database standard form analytic workspaces and associate the custom measures with columns in relational views. You can define temporary custom measures for use during the current session, or you can save them permanently.


Note:

Standard form analytic workspaces, and the relational views that expose their contents, are created by procedures in the DBMS_AWM package.

A custom measure is derived from one or more stored measures. It is calculated at run-time and returned in columns of a view that is structured like a fact table. An example of a custom measure is PROFITS, which is calculated by subtracting the COSTS measure from the SALES measure.

Custom measures created by DBMS_AW_UTILITIES are defined as formulas in an analytic workspace. A formula is a workspace schema object representing a calculation. The result set of a formula includes a value for each workspace dimension member currently in status.


See Also:

Oracle OLAP DML Reference for information on defining formulas and setting dimension status with the OLAP DML.

22.2 Querying Custom Measures

When the CREATE_CUSTOM_MEASURE procedure successfully creates a new custom measure, it provides the following information.

Custom Measure cust_meas_name created in Workspace workspace_name.
 Custom Measure cust_meas_name mapped to column col_name in View view_name.

You can query the specified column to obtain the results of custom measure calculations.

Alternatively, you can query the following tables to obtain information about custom measures created with CREATE_CUSTOM_MEASURE. These tables also provide the name of the columns that contain the results of custom measure calculations.

22.2.1 CWM2$_AW_PERM_CUST_MEAS_MAP

The columns of the CWM2$_AW_PERM_CUST_MEAS_MAP table are described in the following table.

Column Datatype NULL Description
AW_ACCESS_VIEW_NAME VARCHAR2(61) not null Name of the view that contains the permanent custom measure.
CUST_ADT_COLUMN VARCHAR2(30) not null Column in the view.
WORKSPACE_NAME VARCHAR2(61)
Name of the analytic workspace that contains the measures on which the custom measure is based and the formula that defines the custom measure calculation.
AW_MEASURE_NAME VARCHAR2(64)
Name of the derived (custom) measure.
SESSIONID VARCHAR2(10)
ID of the session in which the custom measure was created.
USERNAME VARCHAR2(30)
User that created the custom measure.

22.2.2 CWM2$_AW_TEMP_CUST_MEAS_MAP

The columns of the CWM2$_AW_TEMP_CUST_MEAS_MAP table are described in the following table.

Column Datatype NULL Description
AW_ACCESS_VIEW_NAME VARCHAR2(61) not null Name of the view that contains the temporary custom measure.
CUST_ADT_COLUMN VARCHAR2(30) not null Column in the view.
WORKSPACE_NAME VARCHAR2(61)
Name of the analytic workspace that contains the measures on which the custom measure is based and the formula that defines the custom measure calculation.
AW_MEASURE_NAME VARCHAR2(64)
Name of the derived(custom) measure.
SESSIONID VARCHAR2(10)
ID of the current session. The custom measure only exists in the current session.
USERNAME VARCHAR2(30)
User that created the custom measure.

22.3 Example: Creating a Custom Measure

The following example creates a temporary custom measure in the analytic workspace GLOBAL_AW.GLOBAL. The measure returns the difference between Unit Price and Unit Cost for the cube PRICE_CUBE. The custom measure is returned in the view GLOBAL_AW.GLOB_GLOBA_UNITS_CU10VIEW.

To see the output of your queries, direct output to the screen.

SQL>set serverout on
SQL>exec cwm2_olap_manager.set_echo_on;

You can use the following query to obtain a list of the available analytic workspaces.

SQL>select * from all_olap2_aws where aw = 'GLOBAL';

OWNER                          AW                              AW_NUMBER------------------------------ ------------------------------ ----------GLOBAL_AW                      GLOBAL                               1005

The following query returns a list of the enabled views for cubes in the analytic workspaces.

SQL>select * from all_aw_cube_enabled_views where aw_name = 'GLOBAL';

AW_OWNER  AW_NAME CUBE_NAME  HIERCOMBO_NU HIERCOMBO_STR                    SYSTEM_VIEWNAME          USERP_VIE      
--------- ------- ---------- ------------ ------------------------------   ------------------------ ---------
GLOBAL_AW GLOBAL  PRICE_CUBE   ########## DIM:PRODUCT/HIER:PRODUCT_ROLLUP;  GLOB_GLOBA_PRICE_CU4VIEW
                                          DIM:TIME/HIER:CALENDAR
 
GLOBAL_AW GLOBAL  UNITS_CUBE   ########## DIM:CHANNEL/HIER:CHANNEL_ROLLUP;  GLOB_GLOBA_UNITS_CU9VIEW
                                          DIM:CUSTOMER/HIER:MARKET_ROLLUP;
                                          DIM:PRODUCT/HIER:PRODUCT_ROLLUP;
                                          DIM:TIME/HIER:CALENDAR
 
GLOBAL_AW GLOBAL  UNITS_CUBE   ########## DIM:CHANNEL/HIER:CHANNEL_ROLLUP;   GLOB_GLOBA_UNITS_CU10VIEW
                                          DIM:CUSTOMER/HIER:SHIPMENTS_ROLLUP;
                                          DIM:PRODUCT/HIER:PRODUCT_ROLLUP;
                                          DIM:TIME/HIER:CALENDAR


You can query the following Active Catalog view to obtain the names of the measures in the cubes.

SQL>select * from all_olap2_aw_cube_measures where aw_name = 'GLOBAL';
AW_OWNER   AW_NAM  AW_CUBE_NAM   AW_MEASURE_ AW_PHYSICAL_  MEASURE_SOU  DISPLAY_NAM  DESCRIPTI   IS_AGGR
---------  ------- ----------    ----------  ------------  -----------  -----------  ----------   -----
GLOBAL_AW  GLOBAL  PRICE_CUBE    UNIT_COST    UNIT_COST    UNIT_COST    UNIT COST    Unit Cost    YES
GLOBAL_AW  GLOBAL  PRICE_CUBE    UNIT_PRICE   UNIT_PRICE   UNIT_PRICE   UNIT PRICE   Unit Price   YES
GLOBAL_AW  GLOBAL  UNITS_CUBE    UNITS        UNITS        UNITS        UNITS        Units Sold   YES

The following statement creates a numeric formula PRICE_COST in the analytic workspace GLOBAL in the GLOBAL_AW schema. The formula calculates the difference between unit prices and unit costs. The resulting data is returned in the view GLOBAL_AW.GLOB_GLOBA_UNITS_CU10VIEW.

SQL>execute dbms_aw_utilities.create_custom_measure 
           ('GLOBAL_AW.GLOBAL', 'PRICE_COST', 
            'UNIT_PRICE - UNIT_COST', 'temporary',
            'GLOBAL_AW.GLOB_GLOBA_UNITS_CU10VIEW'); 

Custom Measure 'PRICE_COST' created in Workspace 'GLOBAL_AW.GLOBAL'.Custom Measure 'PRICE_COST' mapped to column 'CUST_MEAS_NUM1' 
               in View 'GLOBAL_AW.GLOB_GLOBA_UNITS_CU10VIEW'.

With the following query, you can see your new custom measure listed in the CWM2$_AW_temp_CUST_MEAS_MAP table.

SQL>select * from olapsys.CWM2$_AW_TEMP_CUST_MEAS_MAP 
                         where workspace_name = 'GLOBAL_AW.GLOBAL';

AW_ACCESS_VIEW_NAME                  CUST_ADT_COLUMN  WORKSPACE_NAME    AW_MEASURE_NAME   SESSIONID  USERNAME-----------------------------------  ---------------  ----------------- --- ------------  ---------- -----GLOBAL_AW.GLOB_GLOBA_UNITS_CU10VIEW  CUST_MEAS_NUM1   GLOBAL_AW.GLOBAL  PRICE_COST          325      MYUSER

To obtain the data resulting from the custom calculation, use the following query.

SQL>select CUST_MEAS_NUM1 from GLOBAL_AW.GLOB_GLOBA_UNITS_CU10VIEW;


Summary of DBMS_AW_UTILITIES Subprograms

Table 22-1 lists the subprograms provided in DBMS_AW_UTILITIES.

Table 22-1 DBMS_AW_UTILITIES

Subprogram Description
CREATE_CUSTOM_MEASURE Procedure
Creates an OLAP formula and associates it with columns in a fact view of an analytic workspace.
DELETE_CUSTOM_MEASURE Procedure
Deletes a custom measure that was created by CREATE_CUSTOM_MEASURE.
UPDATE_CUSTOM_MEASURE Procedure
Changes the definition of an OLAP formula that was created by CREATE_CUSTOM_MEASURE.


CREATE_CUSTOM_MEASURE Procedure

The CREATE_CUSTOM_MEASURE procedure specifies a calculation to be created and stored in a formula object within an analytic workspace. The formula may be defined permanently in the analytic workspace, or it may exist temporarily until the workspace is closed.

CREATE_CUSTOM_MEASURE associates the formula with columns of a fact view. When these columns are queried, the formula calculates the custom measure and populates the columns with the result set. CREATE_CUSTOM_MEASURE assumes that the fact view was previously created by an enablement script generated by the to DBMS_AWM.CREATE_AWCUBE_ACCESS procedure. The view presents the measures of an analytic workspace cube as a set of logical fact tables. There is a separate view for each combination of hierarchies.

The views are created with empty text columns and numeric columns that may be used for custom measures. There are one hundred empty columns of each type.

The text columns are named CUST_MEAS_TEXTn, where n is a number from one to one hundred. The data type is VARCHAR2(1000).

The numeric columns are named CUST_MEAS_NUMn, where n is a number from one to one hundred. The data type is NUMBER.

Syntax

CREATE_CUSTOM_MEASURE(
        aw_name                  VARCHAR2,
        aw_formula_name          VARCHAR2,
        aw_formula_expr          VARCHAR2,
        aw_formula_create_mode   VARCHAR2,
        view_name                VARCHAR2);

Parameters

Table 22-2 CREATE_CUSTOM_MEASURE Procedure Parameters

Parameter Description
aw_name Name of the analytic workspace. The name must be specified in the form owner.name., where owner is the schema name and name is the workspace name.
aw_formula_name Name of the formula to be created in the analytic workspace.
aw_formula_expr A text or numeric expression to be stored in the formula.
aw_formula_create_mode One of the following values:

'PERMANENT' -- Create the formula permanently in the analytic workspace. The workspace will be opened in read/write mode, updated, and committed.

'TEMPORARY' -- Create the formula temporarily in the analytic workspace. The workspace will be opened in read-only mode, and the formula will be discarded when the workspace is closed.

view_name Name of the view that will use the OLAP_TABLE function to access the analytic workspace and read the custom measure data.

Text data will be returned in columns named CUST_MEAS_TEXTn, where n is the next available sequentially numbered column.

Numeric data will be returned in columns named CUST_MEAS_NUMn, where n is the next available sequentially numbered column.


See Also


DELETE_CUSTOM_MEASURE Procedure

The DELETE_CUSTOM_MEASURE procedure deletes a custom measure that was created by CREATE_CUSTOM_MEASURE. It deletes the formula that calculates the custom measure in the analytic workspace and removes the formula from the columns of the fact view.

Syntax

DELETE_CUSTOM_MEASURE(
          aw_name                  VARCHAR2,
          aw_formula_name          VARCHAR2,
          view_name                VARCHAR2);

Parameters

Table 22-3 DELETE_CUSTOM_MEASURE Procedure Parameters

Parameter Description
aw_name Name of the analytic workspace. The name must be specified in the form owner.name., where owner is the schema name and name is the workspace name.
aw_formula_name Name of the formula to be deleted from the analytic workspace.
view_name Name of the view specified by CREATE_CUSTOM_MEA2706345SURE. References to the custom measure will be removed from the columns of the view.


UPDATE_CUSTOM_MEASURE Procedure

This procedure updates the formula for a custom measure in an analytic workspace.

The formula was previously defined and associated with a view by the CREATE_CUSTOM_MEASURE procedure.

Syntax

UPDATE_CUSTOM_MEASURE(
        aw_name                  VARCHAR2,
        aw_formula_name          VARCHAR2,
        aw_formula_expr          VARCHAR2);

Parameters

Table 22-4 UPDATE_CUSTOM_MEASURE Procedure Parameters

Parameter Description
aw_name Name of the analytic workspace. The name must be specified in the form owner.name., where owner is the schema name and name is the workspace name.
aw_formula_name Name of the formula in the analytic workspace.
aw_formula_expr The new calculation to be performed by the formula.