Oracle9i OLAP Services Developer's Guide to the OLAP DML
Release 1 (9.0.1)

Part Number A86720-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

Designing Programs, 5 of 13


Using Variables in Programs

Temporary and local OLAP DML variables

Variables, such as SALES or UNITS, that hold the data in your analytic workspaces are permanent variables. These variables persist from one OLAP Services session to another. However, you might not need to save variables that your programs use to hold processing information while they manipulate data. So that you do not clutter your analytic workspaces with unnecessary variables, you can define temporary and local variables:

Local variables have no dimensions, so you cannot use them for storing dimensioned data. Because they exist only for the duration of the program in which they are defined, you cannot store information in a local variable in one program and then use that variable in another program. If you must store dimensioned data, or use information in more than one program, then you should define a temporary variable instead.

Global versus modular design approaches

The purpose of most OLAP DML programs is to manipulate data. Depending on your programming style and the requirements of your application, you might use either of the following approaches:

Most applications combine these approaches, using permanent and inplace variables and user-defined functions when they are appropriate. In general, modular programs are considered to be easier to read, debug, and maintain.

Defining temporary variables

You define temporary variables with the TEMP keyword in the DEFINE command, as in the following example.

define total.sales decimal temp

Defining temporary variables for use in programs helps you avoid cluttering your analytic workspace with temporary data, but it still adds objects to your analytic workspace. For most simple applications, the addition of a few temporary objects is not a problem. However, in complex applications that require many programs, the number of temporary objects can sometimes get very large, and this can affect the application's performance.

Defining local variables

You must specify local variables at the beginning of your program, before any executable commands. You specify a local variable with the VARIABLE command, which has the following syntax.

VARIABLE name datatype

The name argument specifies the name of the variable. To minimize confusion or problems, you should avoid using the same name for both an analytic workspace variable and a local variable. When both an analytic workspace variable and a local variable have the same name, then the local variable usually takes precedence. However, in a few commands and functions that operate on OLAP DML objects (for example, the OBJ function), the defined variable takes precedence.

The datatype argument specifies the data type of the local variable. A local variable can have a data type of BOOLEAN, DATE, DECIMAL, ID, INTEGER, SHORTDECIMAL, SHORTINTEGER, or TEXT.

For the complete syntax of the VARIABLE command and for a list of the commands and functions for which the defined variable takes precedence, see the entry for the VARIABLE command in OLAP DML Reference. For more information on data types, see "OLAP DML Data Types".

Example: Defining local variables

The program named WEST.RPT, listed below, includes definitions for two local variables named _DATA and _RPT.MONTH.

DEFINE WEST.RPT PROGRAM
LD Produce report for Western Sales District
PROGRAM
variable _data text
variable _rpt.month text
limit month to last 3
   .
   .
   .

Related information

For more information, see the following table.

IF you want documentation about . . .  THEN see . . . 

OLAP DML data types, 

"OLAP DML Data Types" 

permanent variables, 

The topic for the DEFINE VARIABLE command in OLAP DML Reference 

temporary variables, 

The topic for the DEFINE VARIABLE command in OLAP DML Reference 

local variables, 

the topic for the VARIABLE command in OLAP DML Reference 

individual OLAP DML commands, 

the topic for the command in OLAP DML Reference 


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback