Oracle 'open cursor loop fetch into' and 'for in cursor loop'
2017-02-24 15:20
405 查看
例子
for 循环的好处
可以省去定义游标变量,打开游标,关闭游标等操作。代码少,看起来简练;
可以使用匿名游标,将游标写在in和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
for 循环的好处
可以省去定义游标变量,打开游标,关闭游标等操作。代码少,看起来简练;
可以使用匿名游标,将游标写在in和loop中间
相关文章推荐
- PhoneGap: open source development framework for building cross-platform mobile apps, Build apps in HTML and JavaScript
- UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6
- UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6
- Using Single Alert For Messages And Confirmation Messages In Oracle Forms With Set_Alert_Button_Property
- UDEV SCSI Rules Configuration for ASM in Oracle Linux 5, 6 and 7
- PLSQL 循环游标 cursor loop fetch into【转载】
- UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6
- Oracle PLSQL Demo - 10.For Loop遍历游标[FOR LOOP CURSOR]
- Cursor identified in Fetch statement is not open
- UDEV SCSI Rules Configuration for ASM in Oracle Linux 5, 6 and 7
- Dynamic SQL Using OPEN FOR in Oracle PL/SQL
- SSH + Oracle 整合问题之六 There is no Action mapped for namespace / and action name open.
- use ROW_NUMBER() for pagination in Oracle and SQLServer
- Oracle PLSQL Demo - 08.定义显式游标[Define CURSOR, Open, Fetch, Close CURSOR]
- PLSQL 循环游标 cursor loop fetch into【转载】
- UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6
- oracle for in loop 两例
- How to open and close wallet for Oracle Databse 11g?
- Oracle PLSQL Demo - 09.Open、Fetch遍历游标[Open, Fetch, Close Record CURSOR]