The summary of oracle cyclic statements mainly includes the following five types of loops: Exit When, Loop, While, For (Common Loop), and For (cursor Loop). The following are examples (all stored procedures ). 1. Exit When loop: create or replace procedure proc_test_exit_when isi number; begini: = 0; LOOPExit When (I> 5); Dbms_Output.put_line (I); I: = I + 1; www.2cto.com end loop; end Loop; ----------------------- the split line -------------------- 2. LOOP Loop: create or replace procedure proc_test_loop isi number; begini: = 0; loopi: = I + 1; dbms_output.put_line (I); if I> 5 thenexit; end if; end loop; end proc_test_loop ;--------------- ---- The split line -------------------- 3. While loop: create or replace procedure proc_test_while isi number; www.2cto.com begini: = 0; while I <5 loopi: = I + 1; else (I ); end loop; end proc_test_while; --------------------- is the split line -------------------- 4. For general loop: create or replace procedure proc_test_for isi number; begini: = 0; for I in 1 .. 5 loopdbms_output.put_line (I); end loop; end proc_test_for ;------------------ -Split line limit 5 and For cursor loop: create or replace procedure proc_test_cursor isuserRow test % rowtype; cursor userRows isselect * from test; begin www.2cto.com for userRow in userRows limit (userRow. id | ',' | userRow. name | ',' | userRows % rowcount); end loop; end proc_test_cursor; --------------------- refers to the shard line ---------------------- the code of the stored procedure is shown above. You can perform the test as follows: go to pl/SQL, execute file-> New-> program window-> blank, Copy the preceding sections of code to the blank pl/SQL window, and run the F8 command to compile the code. Then execute the file-> New-> command window to enter the command window to execute the set serveroutput on code, and then enter the corresponding exec stored procedure, OK. In the "5th" cycle, you must create a table field named "test" and insert several pieces of data to the table for testing. Prepared by szstephen Zhou