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

Working with Expressions, 2 of 11


Introducing Expressions

Expressions represent data values in the syntax of the OLAP DML. You can use expressions as arguments in commands or functions and as values for options. An expression often performs a mathematical or logical operation. It always evaluates to a result in one of the workspace data types.

An expression can be:

An expression has a data type. It can also have dimensions. The data type and dimensions of an expression depend on the values you are using in the expression.

Data Types of Expressions

The data type of an expression can be one of the following basic types:

These data types are defined in "Data Types".

How the Data Type of an Expression is Determined

The data type of an expression is the data type of the resulting value. It may not be the same as the data type of the data objects that make up the expression; it depends on the data and on the operators and functions that are involved.

In addition, a conditional expression that is indicated by an IF... THEN. . . ELSE operator is supported. A conditional expression returns a value whose data type depends on the expressions in the THEN and ELSE clauses, not on the expression in the IF clause, which must be Boolean.



Note:

Do not confuse a conditional expression with the IF command, which has similar syntax but a different purpose. The IF command does not have a data type and is not evaluated like an expression.


Changing the Data Type of an Expression

You can use the CONVERT function to change data type of an expression. For example, you can convert a number to text, or you can convert a text string that consists of digits to a number.

However, there is no need to convert data to another type within the same basic category because those conversions are made automatically. In general, you can use TEXT, NTEXT, or ID data anywhere text is called for, and you can use integers and decimal numbers interchangeably.

OLAP DML data types are discussed in "Data Types".

Operators

An operator is a symbol that transforms a value or combines it in some way with another value. The following table describes the categories of OLAP DML operators.

Table 4-1 OLAP DML Operators
Category Description

Arithmetic

Operators that you can use in numeric expressions with numeric data to produce a numeric result. You can also use some arithmetic operators in date expressions with a mix of date and numeric data, which returns either a date or numeric result. For more information on arithmetic operators, see Table 4-2, "Arithmetic Operators".

Assignment

An operator that you use to create an assignment statement that stores the results of an expression into an object. For more information on using assignment statements, see "Using Objects in Assignment Statements".

Comparison

Operators that you can use to compare two values of the same basic type (numeric, text, date, or, in rare cases, Boolean), which returns a Boolean result. For more information on comparison operators, see Table 4-3, "Boolean Operators".

Conditional

Operators that you can use to select one of two values based on a Boolean condition. For more information on the substitution operator, see "Conditional Expressions".

Logical

Operators that you can use to transform Boolean values using logical operations, which returns a Boolean result. For more information on logical operators, see Table 4-3, "Boolean Operators".

Substitution

An operator that you can use to evaluate an expression and substitute the resulting value. For more information on the substitution operator, see "Substitution Expressions".

Saving an Expression

You can save an expression in a formula. Typically, you define a formula to save complex or frequently used expressions. A formula is an object that you name and define using the DEFINE FORMULA command.

For example, you can define a formula to calculate dollar sales, as follows.

DEFINE dollar.sales FORMULA units * price

Each time you use a formula, the expression it represents is evaluated. The results are not stored.


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