본문 바로가기

프로그램/oracle

where current of 커서

반응형

일단 명시적 커서를 선언
선언시 for update를 통해 lock 를 획득해놔야 함

cursor emp_list is
    select emp_id from emp
    for update emp_id nowait;
;

for 로프 수행 시 where current of 커서 를 통해
커서가 현재 가르키는 rowid 를 조건으로 걸 수 있음

for cr_emp in emp_list loop
    update emp set sal = cr_emp.sal * 2
    where current of emp_list;
end loop;

* nowait
아마도 다른 곳에서 lock잡았을 시
기둘리는 시간을 말하는거 같음