SYNTAX
{#for variable (range_expression)}
SQL block
{#end}
DESCRIPTION
#FOR operator of syntax 1 executes the SQL block while the variable is
within the range of the range expression.
PARAMETERS
variable
|
Any variable name. Its value is equal to the value from
the range expression for current iteration.
|
range expression
|
A colon separated list of expressions or pairs of 2 expressions separated by ".."
n1 .. n2, n3 .. n4, n5, n6, ....
|
SQL block |
Any SQL command or sequence of commands or part of a command.
It may contain any nested operators.
|
EXAMPLE 1
SQL>?{#for i (1..10)} {i} {#end} /* ? stands for PROMPT */
The result is:
1 2 3 4 5 6 7 8 9 10
EXAMPLE 2
A bit more complex:
SQL>?{#for i (1..4, 77..88, 3)} {i} {#end}
The result is:
1 2 3 4 77 78 79 80 81 82 83 84 85 86 87 88 3
SYNTAX
{#for cursor_variable in string_expression}
SQL block
{#end}
DESCRIPTION
#FOR operator of syntax 2 evaluates the string expression,
then executes it as a SELECT (SQL operator) and executes the SQL block
for every row in the result set. The columns of the cursor can be accessed as follows:
{cursor_name->column_name}
EXAMPLE 1
The following commands analyze all Scott's tables.
SQL>connect scott/tiger@test
Connected to scott@test
SQL>{#for t in "select table_name from user_tables order by table_name"}
SB> analyze table {t->table_name} compute statistics;
SB>{#end}
|