* NOT need: OPEN, FETCH, CLOSE, and variables to hold the fetched data

==> FOR LOOP 문에서 OPEN, FETCH, CLOSE가 자동적으로 실행됨


  * implicit record ( ex. rec_emp_cur )

==> cursor for loop를 벗어나면 접근 불가



declare

 cursor emp_cur is

   select empno, ename, job, sal*1.3 as sal

   from emp

   where deptno = 10;

begin

 for rec_emp_cur in emp_cur loop --> implicit record


   p(rec_emp_cur.job||', '||rec_emp_cur.ename||'('||rec_emp_cur.empno

     ||')''s salary is '||rec_emp_cur.sal);


   p(emp_cur%rowcount||' rows processed');


 end loop;


--  p(emp_cur%rowcount||' rows processed');


--  p(rec_emp_cur.job||', '||rec_emp_cur.ename||'('||rec_emp_cur.empno

--    ||')''s salary is '||rec_emp_cur.sal);

end;

/


+ Recent posts