I. Using a FOR loop cursor:
1. Define a cursor (a cursor is a small collection)
2. Defining cursor Variables
3. Using a For loop cursor
Declare --Define cursor c_job cursor c_job is select Empno, ename, Job, Sal from emp where job = ' MANAGER '; ---Define cursor variable c_row c_row c_job%rowtype;begin -loop cursor, c_row the value of the loop with the cursor variable for c_row in C_job loop Dbms_ Output.put_line (C_row.empno | | '-' || C_row.ename | | '-' || C_row.job | | '-' || C_row.sal); End Loop;end;
2. Fetch cursors:
Must be explicitly turned on and off when used
Declare --Define cursor c_job cursor c_job is select Empno, ename, Job, Sal from emp where job = ' MANAGER '; --Define cursor variable c_row c_row c_job%rowtype;begin open c_job; Loop -Extracts a row of data to C_row fetch c_job into C_row; --the interpretation of whether to extract the value, the value is not taken out of exit when C_job%notfound; Dbms_output.put_line (C_row.empno | | '-' || C_row.ename | | '-' || C_row.job | | '-' || C_row.sal); End Loop; --Closing the cursor close c_job;end;
Using Oracle stored procedures in the middle of the target