SQL$HELP_OLD72.HLB  —  ITERATE Control
    Causes the current iteration of the loop to abort and either the
    next iteration to start or the loop to terminate; depending on
    the termination conditions.

1  –  Environment

    You can use the ITERATE control statement in a compound statement
    of a multistatement procedure:

    o  In interactive SQL

    o  Embedded in host language programs to be precompiled

    o  As part of a procedure in an SQL module

    o  In dynamic SQL as a statement to be dynamically executed

2  –  Format

  ITERATE --+-----------------------+-->
            +-> <statement-label> --+

3  –  Arguments

3.1  –  statement-label

    Names the label assinged to a compound statement or a loop
    statement.

4  –  Example

    Example 1: Using the ITERATE Control Statement

    The following example shows the ITERATE control statement being
    used to prematurely complete the processing of the current row in
    a FOR cursor loop:

    SQL> BEGIN
    cont>   FOR :ord AS TABLE CURSOR ord_cursor
    cont>   AS SELECT * FROM orders WHERE customer_id = :cid
    cont>   DO
    cont>      IF stock_count (:ord.product_id, :ord.quantity) IS NULL THEN
    cont>           ITERATE;
    cont>      END IF;
    cont>      -- transfer stock to this order
    cont>      UPDATE stock SET on_hand = on_hand - :ord.quantity
    cont>       WHERE product_id = :ord.product_id;
    cont>      UPDATE orders SET :ord.available = :ord.quantity
    cont>       WHERE CURRENT OF ord_cursor;
    cont>   END FOR;
    cont> END;
Close Help