oracle pl sql while循环游标

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;
  FETCH C_JOB INTO C_ROW;
  WHILE C_JOB%FOUND LOOP
    DBMS_OUTPUT.put_line(C_ROW.EMPNO || '-' || C_ROW.ENAME || '-' || C_ROW.JOB || '-' || C_ROW.SAL);
    FETCH C_JOB INTO C_ROW;
  END LOOP;
  CLOSE C_JOB;
END;

执行后输出:

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


你可能感兴趣的:(oracle pl sql while循环游标)