Oracle® OLAP DML Reference 11g Release 2 (11.2) E17122-08 |
|
|
PDF · Mobi · ePub |
Use the PARSE command to parse a specified group of expressions. When the argument can be parsed, PARSE determines the number of expressions in it and their text, object type, data type, and the number and names of their dimensions. This information is stored internally by Oracle OLAP, but can be obtained with the INFO function.
A PARSE statement is especially useful when you want to accept expressions as arguments to a program.
A text expression that contains one or more smaller expressions to be parsed. When you are processing program arguments, you can specify an ARGS function as the text expression that contains all the arguments for the program.
Obtaining Information Produced by a PARSE Statement
See the INFO (PARSE) function for an explanation of how to obtain the information produced by a PARSE statement.
Example 10-72 Parsing the Arguments to a Program
In a simple report program, you want to specify the data to be reported as an argument to the program. You want to be able to specify an expression and the name of a data variable.
Suppose you want to display each of the arguments with a different column width, which means you must process the arguments individually. The ARGS function can only process them together. So you use PARSE and INFO to parse the arguments and produce individual columns for each of them. Here is a sample program.
DEFINE report1 PROGRAM PROGRAM PUSH month product district DECIMALS DECIMALS = 0 LIMIT month TO FIRST 2 LIMIT product TO ALL LIMIT district TO 'Chicago' PARSE ARGS REPORT ACROSS month WIDTH 8 <&INFO(PARSE FORMULA 1) - WIDTH 13 &INFO(PARSE FORMULA 2)> POP month product district DECIMALS END
When you run the program, you can supply either the names of variables (such as sales
) or expressions (such as sales-expense
) or one of each as arguments. The following REPORT statement produces the illustrated report.
report1 sales sales-expense DISTRICT: CHICAGO --------------------MONTH-------------------- --------JAN95--------- --------FEB95--------- PRODUCT SALES SALES-EXPENSE SALES SALES-EXPENSE ------------ -------- ------------- -------- ------------- Tents 29,099 1,595 29,010 1,505 Canoes 45,278 292 50,596 477 Racquets 54,270 1,400 58,158 1,863 Sportswear 72,123 7,719 80,072 9,333 Footwear 90,288 8,117 96,539 13,847