compoundstatement

NAME
SYNTAX
DESCRIPTION
EXAMPLES
COPYRIGHT
SEE ALSO

NAME

compoundstatement − RWP*Load Simulator compound statements

SYNTAX

compoundstatement ::=
  ifstatement
| whilestatement
| counterloop
| listloop
| executionblock
| cursorloop
| readloop
| controlloop

ifstatement ::=
  if expression then
    statementlist
    [ { elseif expression then statementlist } ]
    [ else statementlist ]
  end [ if ]

whilestatement ::=
  while expression loop
    statementlist
  end [ loop ]

counterloop ::=
  for identifier := expression .. expression
  loop
    statementlist
  end [ loop ]

listloop ::=
  for identifier := concatenation , concatenation { , concatenation }
  loop
    statementlist
  end [ loop ]


executionblock ::=
  execute [ atclause ]
    statementlist
  end [ execute ]

DESCRIPTION

Compound statements are used to wrap statement lists typically for conditional or repeated execution. The control loop is described separately, the rest are described here.

if e then s;s;s; end

if e then s;s;s; else s;s;s; end

if e then s;s;s; elseif e then s;s;s; end

if e then s;s;s; elseif e then s;s;s; else s;s;s; end

The expression, e, between if and then is evaluated and if non-zero, the statements after then are executed. You can follow this by zero or more elseif parts which implies at most one of the statement lists until the final end will be executed. You can optionally have an else and a statement list before end, which will be executed if all if expressions are false. If an expression evaluates to null, a warning is shown and the statement list after then will not be executed.

while e loop s;s;s; end

Execute the statement list between the loop keywords and the end keyword while the expression, e, is true (non-zero). If the expression is zero when the while loop is entered, no execution of the statement list takes place.

for v := lo .. hi loop s;s;s; end

The named variable, v, loops through the values of the expressions, lo and hi, and the statement list between loop and end is executed once with each value. The increment after each loop is one and it is recommended that the variable is of type integer. If the value lo initially is higher than the value hi, no statements are executed. The value hi is re-evaluated as an expression before each comparison to the value of the variable.

for v := e1 , e2 , e3 loop s;s;s; end

The named variable, v, loops through the comma separated list of concatenations and the statement list between loop and end is executed once with each value. There must be at least two concatenations in the list.

execute at d s;s;s; end

The primary purpose of the execute block is to handle a list of statements as one in particular when dealing with database connections. If you don’t have a default database, you cannot execute any sql or database statement without specifying the at clause and using the execute block allows you to just have a single at clause that will be used for the statement list wrapped within the execute block. The variable, d, must refer to a database and if any of the statements in the list needs a database (e.g. executing sql), the whole execute block will have a database session upon start, that is released when finished.

Note that even if you have a default database, you need to use an execute block if your main program executes any dml or database statements such as commit.

The readloop is described in filestatement(1rwl), the cursorloop in sqlexecution(1rwl) and the controlloop in controlloop(1rwl).

EXAMPLES

Still to come.

COPYRIGHT

Copyright © 2023 Oracle Corporation
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl

SEE ALSO

controlloop(1rwl), identifier(1rwl), regex(1rwl), regexextract(1rwl), sqlexecution(1rwl), filestatement(1rwl), atclause(1rwl), statementlist(1rwl), databasestatement(1rwl), expression(1rwl)