is variable up to the declared size. Arguably then, variable-sized arrays aren't that variable in size. Cursors A cursor is a pointer to a private SQL area that stores information coming from a SELECT or data manipulation language (DML) statement (INSERT, UPDATE, DELETE, or MERGE). A cursor holds the rows (one or more) returned by a SQL statement. The set of rows the cursor holds is referred to as the active set. A cursor can be explicit or implicit. In a FOR loop, an explicit cursor shall be used if the query will be reused, otherwise an implicit cursor is preferred. If using a cursor inside a loop, use a FETCH is recommended when needing to bulk collect or when needing dynamic SQL. Looping As a procedural language by definition, PL/SQL provides several iteration constructs, including basic LOOP statements, WHILE loops, FOR loops, and Cursor FOR loops. Since Oracle 7.3 the REF CURSOR type was introduced to allow recordsets to be returned from stored procedures and functions. Oracle 9i introduced the predefined SYS_REFCURSOR type, meaning we no longer have to define our own REF CURSOR types. LOOP statements <<parent_loop>> LOOP statements <<child_loop>> loop statements exit parent_loop when <condition>; -- Terminates both loops exit when <condition>; -- Returns control to parent_loop end loop child_loop; if <condition> then continue; -- continue to next iteration end if; exit when <condition>; END LOOP parent_loop; Loops can be terminated by using the EXIT keyword, or by raising an exception. FOR loops DECLARE var NUMBER; BEGIN /* N.B. for loop variables in PL/SQL are new declarations, with scope only inside the loop */ FOR var IN 0 .. 10 LOOP DBMS_OUTPUT.PUT_LINE(var); END LOOP; IF var IS NULL THEN DBMS_OUTPUT.PUT_LINE('var is null'); ELSE DBMS_OUTPUT.PUT_LINE('var is not null'); END IF; END; Output: 0 1 2 3 4 5 6 7 8 9 10 var is null Cursor FOR loops FOR RecordIndex IN (SELECT person_code FROM people_table) LOOP DBMS_OUTPUT.PUT_LINE(RecordIndex.person_code); END LOOP; Cursor-for loops automatically open a cursor, read in their data and close the cursor again. As an alternative, the PL/SQL programmer can pre-define the cursor's SELECT-statement in advance to (for example) allow re-use or make the code more understandable (especially useful in the case of long or complex queries). DECLARE CURSOR cursor_person IS SELECT person_code FROM people_table; BEGIN FOR RecordIndex IN cursor_person LOOP DBMS_OUTPUT.PUT_LINE(recordIndex.person_code); END LOOP; END; The concept of the person_code within the FOR-loop gets expressed with