pl/sql帶引數的遊標和可更新的遊標案列
阿新 • • 發佈:2019-02-06
--pl/sql帶引數的遊標案列 declare cursor c(v_deptno dept.deptno%type,v_job emp.job%type) is select ename,sal from emp where deptno=v_deptno and job = v_job; begin for v_emp in c(30,'SALESMAN') loop--給遊標傳遞引數 dbms_output.put_line(v_emp.ename); end loop; end; --pl/sql可更新的遊標案列 declare cursor c is select * from emp2 for update; begin for v_emp in c loop if (v_emp.sal < 2000) then update emp2 set sal = sal*2 where current of c; elsif (v_emp.sal = 3000) then delete from emp2 where current of c; end if; end loop; commit;--事務提交 end;