Register now and start sharing your code snippets.
-->
Example of how to do a for loop with PL/SQL
SQL posted about 1 year ago by christian
A PL /SQL example of a for loop that prints out the primary key for all rows returned by a query:
1 DECLARE 2 ID VARCHAR2(50); 3 BEGIN 4 DBMS_OUTPUT.ENABLE (1000000); 5 FOR current_row IN (SELECT id FROM your_table) 6 LOOP 7 ID := current_row.id; -- Assign value to variable 8 DBMS_OUTPUT.PUT_LINE( '' || ID); 9 DBMS_OUTPUT.PUT_LINE( '' || current_row.column_xxx); 10 END LOOP; 11 END; 12 /