oracle pl sql fetch游标

EMP表在SCOTT用户下。用SCOTT/TIGER登录。

代码:

DECLARE
CURSOR C_JOB IS SELECT EMPNO, ENAME, JOB, SAL FROM EMP WHERE JOB = 'MANAGER';
C_ROW C_JOB%ROWTYPE;
BEGIN
  OPEN C_JOB;
  LOOP
    FETCH C_JOB INTO C_ROW;
    EXIT WHEN C_JOB%NOTFOUND;
    DBMS_OUTPUT.put_line(C_ROW.EMPNO || '-' || C_ROW.ENAME || '-' || C_ROW.JOB || '-' || C_ROW.SAL);
  END LOOP;
  CLOSE C_JOB;
END;

执行后输出:

7566-JONES-MANAGER-2975
7698-BLAKE-MANAGER-2850
7782-CLARK-MANAGER-2450


你可能感兴趣的:(oracle pl sql fetch游标)