|Oracle® Database PL/SQL Language Reference
11g Release 2 (11.2)
Part Number E17126-03
LOOP statement implicitly declares its loop index as a record variable of the row type that a specified cursor returns and opens a cursor. With each iteration, the cursor
LOOP statement fetches a row from the result set into the record. When there are no more rows to fetch, the cursor
LOOP statement closes the cursor. The cursor also closes if a statement inside the loop transfers control outside the loop or if PL/SQL raises an exception.
See "statement ::=".
An identifier for the loop index that the cursor
LOOP statement implicitly declares as a
%ROWTYPE record variable of the type that
record_name is local to the cursor
LOOP statement. Statements inside the loop can reference
record_name and its fields. They can reference calculated columns only by aliases. Statements outside the loop cannot reference
record_name. After the cursor
LOOP statement runs,
record_name is undefined.
The name of an explicit cursor that is not open when the cursor
LOOP is entered.
An actual parameter that corresponds to a formal parameter of the explicit cursor
cursor_name. For more information, see "Explicit Cursors that Accept Parameters".
SELECT statement (not a PL/SQL
INTO statement). For this
SELECT statement, PL/SQL declares, opens, fetches from, and closes an implicit cursor. However, because
select_statement is not an independent statement, the implicit cursor is internal—you cannot reference it with the name
See Also:Oracle Database SQL Language Reference for
Labels improve readability, especially when
LOOP statements are nested, but only if you ensure that the label in the
LOOP statement matches a label at the beginning of the same
LOOP statement (the compiler does not check).
In this chapter:
In other chapters: