Oracle9i OLAP Services Developer's Guide to the OLAP DML Release 1 (9.0.1) Part Number A86720-01 |
|
Working with Expressions, 13 of 14
A substitution expression allows you to substitute the value of the expression for the expression itself in a command or function.
To construct a substitution expression, use an ampersand character (&) at the beginning of an expression. Using an ampersand (that is, the substitution operator) this way is also called ampersand substitution. The ampersand specifies that the expression should be evaluated with the ampersand and substitute the resulting value before it evaluates the rest of the expression.
Ampersand substitution gives you a level of indirection when you are specifying an expression. For example, when you specify an ampersand followed by a variable that holds the name of another variable, the value of the expression becomes the data in the second variable. Ampersand substitution lets you write more general programs that can operate on data that is chosen when the program is run.
Note: You cannot use ampersand substitution in model equations.
Suppose you have a variable called CURNAME that holds the name of one of the dimensions in the analytic workspace (PRODUCT). If you execute the following command, then REPORT produces the single value, PRODUCT, which is the actual value stored in the CURNAME variable, as shown below.
report curname CURNAME ---------- PRODUCT
However, if you execute the following command, then REPORT produces the values of the dimension PRODUCT, as shown below.
report &curname PRODUCT -------------- TENTS CANOES RACQUETS SPORTSWEAR FOOTWEAR
Although ampersand substitution lets you write more general programs that can handle different variables and data, program lines that use ampersand substitution are executed less efficiently. Lines with ampersand substitution are not compiled; instead these lines are interpreted when the program runs.
To avoid ampersand substitution, you can use the IF or SWITCH command instead. For more information about the IF or SWITCH command, see the entry for the command in the OLAP DML Reference.
For more information, see the following table.
IF you want documentation about . . . | THEN see . . . |
---|---|
IF and SWITCH commands, |
the entry for the command in the OLAP DML Reference |
writing conditional commands in the OLAP DML, |
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|