Ⅰ.在存储过程中使用游标
①声明游标
CURSOR CUR_EMP IS SELECT * FROM EMP ;
②打开游标
③循环取数
④设置退出条件
⑤关闭循环
⑥关闭游标
CREATE OR REPLACE PROCEDURE PRO_EMP_TEST IS EMP_T EMP % ROWTYPE; CURSOR CUR_EMP IS SELECT * FROM EMP ; BEGIN OPEN CUR_EMP; LOOP FETCH CUR_EMP INTO EMP_T ; EXIT WHEN CUR_EMP % NOTFOUND; DBMS_OUTPUT.PUT(EMP_T.EMPNO || ' ' ); DBMS_OUTPUT.put_line(EMP_T.ENAME); END LOOP; CLOSE CUR_EMP; END PRO_EMP_TEST;