1. 程式人生 > >Oracle 帶引數遊標

Oracle 帶引數遊標

-- 引數遊標
declare
   cursor mycur(dno number) is select empno,ename,job,deptno from emp where deptno=dno;
begin
  for record in mycur(10) loop
    dbms_output.put_line('員工編號:'||record.empno||' 員工名稱:'||record.ename||' 員工職位:'||record.job||' 員工部門:'||record.deptno);
  end loop;
end;

-- 從視窗輸入值
declare
   cursor mycur(dno number) is select empno,ename,job,deptno from emp where deptno=dno;
begin
  for record in mycur(&no) loop
    dbms_output.put_line(' 員工編號:'||record.empno||' 員工名稱:'||record.ename||' 員工職位:'||record.job||' 員工部門:'||record.deptno);
  end loop;
end;