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;
/