问答详情
源自:3-5 PL/SQL光标之带参数的光标

pl/sql中的带参数的光标问题

set serveroutput on

declare 

cursor cemp(dno number) is select ename from emp where empno=dno;

pename emp.ename%type;


begin

open cemp(10);

LOOP

fetch cemp into pename;

exit when cemp%notfound;

dbms_output.put_line(pename);

end loop;


close cemp;

end;

/


提问者:judyW 2017-06-01 15:38

个回答

  • HelloiM00c
    2017-06-01 17:24:31
    已采纳

    SQL--> select ename, empno from emp;
    
    ENAME      EMPNO                  
    ---------- ---------------------- 
    SMITH      7369                   
    ALLEN      7499                   
    WARD       7521                   
    JONES      7566                   
    MARTIN     7654                   
    BLAKE      7698                   
    CLARK      7782                   
    SCOTT      7788                   
    KING       7839                   
    TURNER     7844                   
    ADAMS      7876                   
    JAMES      7900                   
    FORD       7902                   
    MILLER     7934

    将参数dno赋值7369等值,就可以了