Previous
Previous
 
Next
Next

Program Flow-of-Control

Like most programming languages, the OLAP DML has several statements that you can use to determine the flow-of-control within a program. However, you must code explicit loops less frequently in an OLAP DML program because of the intrinsic looping nature of many OLAP DML statements.

Table: Statements For Determining Flow-of-Control lists OLAP DML flow-of-control statements. The looping characteristic of OLAP DML statements is discussed in "OLAP DML Statements Apply to All of the Values of a Data Object".

The OLAP DML contains the flow-of-control statements typically found in a programming language. Table: Statements For Determining Flow-of-Control lists these statements.

Statements For Determining Flow-of-Control

Statement Description

BREAK


Transfers program control from within a SWITCH, FOR, or WHILE statement to the statement immediately following the DOEND associated with SWITCH, FOR, or WHILE.

CONTINUE


Transfers program control to the end of a FOR or WHILE loop (just before the DO/DOEND statement), allowing the loop to repeat. You can use CONTINUE only within programs and only with FOR or WHILE.

DO ... DOEND


Brackets a group of one or more statements. DO and DOEND are normally used to bracket a group of statements that are to be executed under a condition specified by an IF statement, a group of statements in a repeating loop introduced by FOR or WHILE, or the CASE labels for a SWITCH statement.

FOR


Specifies one or more dimensions whose status controls the repetition of one or more statements.

GOTO


Alters the sequence of statement execution within the program by indicating the next program statement to execute.

IF...THEN...ELSE command


Executes one or more statements in a program if a specified condition is met. Optionally, it also executes an alternative statement or group of statements when the condition is not met.

OKFORLIMIT


An option that determines whether you can limit the dimension you are looping over within an explicit FOR loop.

RETURN


Terminates execution of a program before its last line. You can optionally specify a value that the program returns.

SIGNAL


Produces an error message and halts normal execution of the program. When the program contains an active trap label, execution branches to the label. Without a trap label, execution of the program terminates and, if the program was called by another program, execution control returns to the calling program.

SWITCH command


Provides a multipath branch in a program. The specific path taken during program execution depends on the value of the control expression that is specified with SWITCH.

TEMPSTAT


Limits the dimension you are looping over, inside a FOR loop or inside a loop that is generated by a REPORT statement. Status is restored after the statement following TEMPSTAT. If a DO ... DOEND phrase follows TEMPSTAT, status is restored when the matched DOEND or a BREAK or GOTO statement is encountered.

TRAP


Causes program execution to branch to a label when an error occurs in a program or when the user interrupts the program. When execution branches to the trap label, that label is deactivated.

WHILE


Repeatedly executes a statement while the value of a Boolean expression remains TRUE.