正確分析Oracle數據的隱式遊標

Oracle隱式遊標:
 
不用明確建立遊標變量,Oracle隱式遊標分兩種:
 
1.在PL/SQL中使用DML語言,使用ORACLE提供的名爲“SQL”的隱示遊標。
 
舉例:
 
declare  
 
begin  
 
 update departments set department_namedepartment_name=department_name;  
 
 --where 1=2;  
 
 dbms_output.put_line('update '|| sql%rowcount ||' records');  
 
end;  
 
/  
2.CURSOR FOR LOOP,用於for loop 語句
 
舉例:
 
declare  
 
begin  
 
 for my_dept_rec in ( select department_name, department_id from departments)  
 
 loop  
 
 dbms_output.put_line(my_dept_rec.department_id || ' : ' || my_dept_rec.department_name);  
 
 end loop;  
 
end;  
 
/  

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章