Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SPL Statements > FOR >

Using an Expression List as the Range

The database server initializes the value of loop_var to the value of the first expression specified. In subsequent iterations, loop_var takes on the value of the next expression. When the database server has evaluated the last expression in the list and used it, the loop stops.

The expressions in the IN list do not need to be numeric values, as long as you do not use range operators in the IN list. The following example uses a character expression list:

FOR c IN ('hello', (SELECT name FROM t), 'world', v1, v2)
   INSERT INTO t VALUES (c);
END FOR

The following FOR statement shows the use of a numeric expression list:

FOR index IN (15,16,17,18,19,20,21)
   -- statement block
END FOR
Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]