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

Populating Workspace Data Objects, 4 of 5


Assigning Values to Data Objects

An expression creates temporary data; you can display the resulting values, but these values are not automatically saved in your analytic workspace. If you want to save the result of an expression, then you store it in an object that has the same data type and dimensions as the expression. You use an assignment statement to store the value that is the result of the expression in the object.

An assignment statement is composed of the OLAP DML = operator that is preceded by an expression (on the left) and followed by an expression (on the right).

target-expression = source-expression

The assignment statement sets the value of the target expression equal to the results of the source expression.


See Also:

Chapter 3, "Defining Data Objects" for information about how data is stored in data objects.

Using Objects in Assignment Statements

The following table outlines the objects that you can use in assignment statements and indicates whether you can use them as a target or source expression.

Object

Target Expression

Source Expression

Variable

Yes

Yes

Relation

Yes

Yes

Dimension

Only in models

Yes

Surrogate

No

Yes

Composite

No

Yes

Worksheet

Yes

Yes

Function

No

Yes

Formula

No

Yes

Valueset

No

Yes



When you use the = operator to assign the value of a single-cell expression to a single cell, a single value is stored. However, when you use the = operator to assign the value of a single-cell expression to a target variable that has one or more dimensions, then the assignment loops over the values in status for each dimension of the target variable and assigns a data value to the corresponding cells of the variable.

Example 5-3 Assigning Values to Variables

The choicedesc variable is dimensioned by choice. Before you enter data for the variable, the cells of the variable contain only NA values.

CHOICE           CHOICEDESC
-------------- --------------------
REPORT         NA
GRAPH          NA
ANALYZE        NA
DATA           NA
QUIT           NA

Suppose you initialize the choicedesc variable using the following command.

choicedesc =  JOINCHARS ('Description for ' choice)

Now all of the choicedesc cells of the variable contain the appropriate values.

CHOICE             CHOICEDESC
-------------- -------------------------
REPORT         Description for REPORT
GRAPH          Description for GRAPH
ANALYZE        Description for ANALYZE
DATA           Description for DATA
QUIT           Description for QUIT

The next example shows an expression that is dimensioned by time, product, and district and is assigned to a new variable. The expression calculates a 2002 sales plan based on unit sales in 2001.

DEFINE units.plan INTEGER <month product district>
LIMIT month TO 'DEC02'
units.plan = LAG(units 12 month) * 1.15

How Values Are Assigned to Variables with Composites

When assigning data to variables with composites, the source expression is evaluated for every combination of the dimension values in status for the target variable, including combinations of the sparse dimensions for which the target variable currently has no cells. If the source expression is not NA for those combinations where the target currently has no cells, then new cells are created and the data is assigned to them.

When you use the = command to assign values to a target variable that has a composite, the command does the following automatically:

Thus, both the target variable and the composite might be larger after an assignment. If you want to assign values only to cells that already exist in the target variable, then use the ACROSS keyword in the = command.

The OLAP DML gives you the ability to specify a different evaluation behavior when it assigns data to variables with composites. You can alter the default evaluation behavior of the assignment statement so that the source expression is evaluated only for those combinations of the dimension values in status for which the target variable currently has cells.

Because the composite of the sparse dimension is what keeps track of which combinations of the sparse dimensions have data cells, you use the following syntax to specify this different evaluation behavior.

varname = expression ACROSS composite

The varname argument is the name of the variable. It is the target to which the data is assigned.

The expression argument is the source expression that holds the data that will be assigned to the target variable.

The ACROSS keyword indicates that you want to alter the default evaluation behavior and cause the evaluation of the composite of the target variable.

The composite argument is the composite for the sparse dimensions on the target variable. If the variable was defined with a named composite, then specify the name of the composite. If the variable was defined with an unnamed composite, then use the SPARSE keyword to refer to the unnamed composite (for example, SPARSE <MARKET PRODUCT>).

Example 5-4 Assigning Values to Variables with Composites

To have data assigned from sales only into existing data cells of sparse_sales, whose associated dimension values are in status, use the following command.

sparse_sales = sales ACROSS SPARSE<product market>

The ACROSS keyword is particularly helpful when the source expression is a single value. If there are no limits on the dimensions of sparse_sales, then an assignment command like the following will create cells for every combination of dimension values because there are no cases where the source expression is NA.

sparse_sales = 0

This defeats the purpose of a sparse variable.

In contrast, the following command will set only existing cells of sparse_sales to 0.

sparse_sales = 0 ACROSS SPARSE<product market>

Assigning Values to Relations

You can assign values to a relation using an assignment statement. When executing the assignment statement, a loop is performed over the values in status for each dimension of the target relation and assigns a data value to the corresponding cell of the target relation.

You can assign values to a relation with a text dimension by assigning one of the following:

Assigning Values to Dimensions

In most cases, you cannot use an assignment statement to assign values to dimensions. However, in model equations, if the result of a calculation is numeric, then you can use the = operator to assign the results to a dimension value. However, equations (that is, expressions) in models differ in several ways from expressions used in other contexts.


See Also:

Chapter 8, "Working with Models" for more information on working with models.

Assigning Values to Specific Cells of a Data Object

You can use a QDR with the target of an assignment statement. This lets you assign a value to specific cells in a variable or relation.

The following example assigns the value 10200 to the data cell of the sales variable that is specified in the qualified data reference. If the variable named sales does not already have a value in the cell associated with BOSTON, TENTS, and JAN99, then the value is assigned to the cell and thus it is added to the variable. If a value already exists in the cell, the value 10200 overwrites the previous value.

sales(market 'BOSTON' product 'TENTS' month 'JAN99')= 10200

See Also:

"Specifying a Single Value for the Dimension of an Expression" for information about QDRs.


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