Oracle® OLAP DML Reference 10g Release 1 (10.1) Part Number B10339-02 |
|
|
View PDF |
Within an OLAP DML program, the ARGS function lets you reference the arguments that are passed to a program. The function returns all the arguments as a single text value. You can use the ARGS function only within a program that is be invoked as a command, not as a user-defined function or with a CALL statement.
Note: Use an ARGUMENT statement to define arguments in a program and to negate the need for using the ARGS function to reference arguments passed to the program. For more information on how to use the ARGUMENT to define arguments that are passed to a program, see "Declaring Arguments that Will be Passed Into a Program" . |
Important: When you want to pass NTEXT arguments, be sure to declare them using ARGUMENT instead of using ARGS. With ARGS, NTEXT arguments are converted to TEXT, and this can result in data loss when the NTEXT values cannot be represented in the database character set. |
Return Value
TEXT
Syntax
ARGS
Notes
When no arguments have been specified for the program, ARGS returns a null value.
The ARGS function is often preceded by an ampersand (&
) in a program line to allow flexibility in specifying arguments; in other words, to tell Oracle OLAP not to pass the literal contents of ARGS into the program, but what the contents point to. (See "Passing Arguments Using ARGS".
To reference a single argument use ARG, or to reference a group of arguments beginning with a specified argument use ARGFR.
A program can include an ARGCOUNT function to verify the number of arguments passed to the program.
In most cases, either commas or spaces can be used between arguments. However, arguments may need to be separated with commas when those arguments include parentheses or negative numbers. Without commas, Oracle OLAP might interpret parenthetical expressions as qualified data references and negative signs as subtraction.
You can use CALLTYPE to determine whether a program was invoked as a function, as a command, or by using CALL.
Examples
Example 8-6 Passing Arguments Using ARGS
Assume you have a program that produces a simple sales report. You want to be able to produce this report for any month, so you do not want to limit the month
dimension to any fixed month in the program. You can use the ARGS function in your LIMIT command so that the months for the report can be supplied as an argument when the program is run.
When ARGS is included in the LIMIT command preceded by an ampersand (&
), Oracle OLAP substitutes the values of &ARGS
before the command is executed and, as a result, treats the whole argument as a phrase of the LIMIT command. The salesreport
program has a LIMIT command that includes &ARGS
.
DEFINE salesrpt PROGRAM PROGRAM PUSH month product district TRAP ON cleanup LIMIT month TO &ARGS LIMIT product TO 'CANOES' LIMIT district TO ALL REPORT grandtotals DOWN district sales cleanup: POP month product district END
When you execute the following statement, the LIMIT command will use the values Jan96
and Feb96
for the month
dimension.
salesrpt 'Jan96' 'Feb96'
The statement produces the following output.
PRODUCT: CANOES --------SALES-------- --------MONTH-------- DISTRICT Jan96 Feb96 ---------------------------------- Boston 70,489.44 82,237.68 Atlanta 56,271.40 61,828.33 Chicago 48,661.74 54,424.94 Dallas 35,244.72 40,218.43 Denver 44,456.41 50,623.19 Seattle 67,085.12 74,834.29 ---------- ---------- -- 322,208.83 364,166.86 ========== ========== ==