Oracle's Stored Procedure Programming Lecture 8: The Use of Cursors

The use of cursors Cursor in Oracle is very useful for traversing query results in temporary tables.

 

Query "ename" and "deptno" in the emp table and store them in the cusor_01 cursor. The for loop iterates the cursor collection. The result of each iteration is stored in 'c'.


create or replace procedure test01 is
 
   
       cursor cusor_1 is select ename,deptno from emp ;--Define a cursor
 
begin
 
       for c in cusor_1 loop
           dbms_output.put_line('Employee name:'||c.ename||' Department number:'||c.deptno);
       end loop;
  
    
 
end test01;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326566019&siteId=291194637