Oracle 'open cursor loop fetch into' and 'for in cursor loop'

前端之家收集整理的这篇文章主要介绍了Oracle 'open cursor loop fetch into' and 'for in cursor loop'前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  • 例子
DECLARE

CURSOR emp IS
SELECT first_name,last_name FROM hr.employees;

my_emp2 emp%ROWTYPE;

fir_name hr.employees.first_name%TYPE;

BEGIN WITH emp_temp AS ( SELECT first_name FROM hr.employees WHERE first_name = 'Ellen' ) SELECT first_name INTO fir_name FROM emp_temp;

DBMS_OUTPUT.PUT_LINE( 'first_name -- ' || fir_name );


OPEN emp;

LOOP

FETCH emp INTO my_emp2;
EXIT WHEN emp%NOTFOUND;



DBMS_OUTPUT.PUT_LINE( 'fetch -- ' || my_emp2.first_name || '-' || my_emp2.last_name );

END LOOP;

CLOSE emp;

FOR eachemp IN emp LOOP
DBMS_OUTPUT.PUT_LINE( 'for -- ' || eachemp.first_name || '-' || eachemp.last_name );
END LOOP;

END;
/


SELECT * FROM V$OPEN_CURSOR 
原文链接:https://www.f2er.com/oracle/210435.html

猜你在找的Oracle相关文章