Skip Headers

Oracle9i OLAP Developer's Guide to the OLAP DML
Release 2 (9.2)

Part Number A95298-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

Developing Programs, 4 of 12


Using Variables in Programs

Variables that hold the data in your analytic workspaces are permanent variables. These variables persist from one OLAP 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:

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 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.

Once defined, a temporary variable will exist for the remainder of a user's session unless it is deleted. Be sure to delete the temporary variable as part of the cleanup of your program, or create it on the condition that it does not already exist, so that it can be rerun during a session without causing an error.

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 workspace objects (for example, the OBJ function), the defined variable takes precedence.

The datatype argument specifies the data type of the local variable. For more information on data types, see "Data Types".

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
   .
   .
   .

Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2001, 2002 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