trap or bug when using CONTINUE in Oracle 11g
2011-05-17 16:56
609 查看
CONTINUE is a new feature brought in Oracle 11g, but there is a trap or bug need to pay attention, see the following code scrap:
Output:
As you see, CONTINUE didn't work correctly in implicit cursor loop!!!
DECLARE CURSOR dept_cur IS SELECT deptno ,dname ,loc FROM scott.dept; TYPE dept_tab IS TABLE OF dept_cur%ROWTYPE INDEX BY BINARY_INTEGER; l_dept_tab dept_tab; BEGIN --EXECUTE IMMEDIATE 'ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL = 1'; --http://pbarut.blogspot.com/2009/04/caution-for-loop-and-continue-in-oracle.html dbms_output.put_line('==========OracleVersion========='); FOR ver_rec IN (SELECT banner FROM v$version) LOOP dbms_output.put_line(ver_rec.banner); END LOOP; --review test data dbms_output.put_line('==========dept_loop0========='); <<dept_loop0>> FOR dept_rec IN dept_cur LOOP dbms_output.put_line(dept_rec.deptno || ', ' || dept_rec.dname || ', ' || dept_rec.loc); END LOOP dept_loop0; --CONTINUE in implicit cursor dbms_output.put_line('==========dept_loop1========='); <<dept_loop1>> FOR dept_rec IN dept_cur LOOP IF (dept_rec.deptno = '30') THEN continue dept_loop1; END IF; dbms_output.put_line(dept_rec.deptno || ', ' || dept_rec.dname || ', ' || dept_rec.loc); END LOOP dept_loop1; --CONTINUE in explicit cursor dbms_output.put_line('==========dept_loop2========='); OPEN dept_cur; FETCH dept_cur BULK COLLECT INTO l_dept_tab; CLOSE dept_cur; <<dept_loop2>> FOR i IN 1 .. l_dept_tab.COUNT LOOP IF (l_dept_tab(i).deptno = '30') THEN continue dept_loop2; END IF; dbms_output.put_line(l_dept_tab(i).deptno || ', ' || l_dept_tab(i) .dname || ', ' || l_dept_tab(i).loc); END LOOP dept_loop2; END;
Output:
==========OracleVersion========= Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production PL/SQL Release 11.1.0.7.0 - Production CORE 11.1.0.7.0 Production TNS for Solaris: Version 11.1.0.7.0 - Production NLSRTL Version 11.1.0.7.0 - Production ==========dept_loop0========= 10, ACCOUNTING, NEW YORK 20, RESEARCH, DALLAS 30, SALES, CHICAGO 40, OPERATIONS, BOSTON 50, name1, loc1 51, name1, name1 52, loc1, loc1 ==========dept_loop1========= 10, ACCOUNTING, NEW YORK 20, RESEARCH, DALLAS ==========dept_loop2========= 10, ACCOUNTING, NEW YORK 20, RESEARCH, DALLAS 40, OPERATIONS, BOSTON 50, name1, loc1 51, name1, name1 52, loc1, loc1
As you see, CONTINUE didn't work correctly in implicit cursor loop!!!
相关文章推荐
- trap or bug when using CONTINUE in Oracle 11g
- trap or bug when using CONTINUE in Oracle 11g
- Oracle 11g 11.2.0.2 Bug 10082277 – Excessive allocation in PCUR or KGLH0 heap of “kkscsAddChildNo”
- Oracle 11g 11.2.0.2 Bug 10082277 – Excessive allocation in PCUR or KGLH0 heap of “kkscsAddChildNo”
- Oracle 11g 11.2.0.2 Bug 10082277 – Excessive allocation in PCUR or KGLH0 heap of “kkscsAddChildNo”
- Auto-declare fails when using Oracle 11g R2 and WebSphere Application Server 6.1
- Using Intermediate Events and Advanced TaskService Interactions in Oracle BPM Suite 11g
- An Example Of Validating Text Item In Oracle Forms Using When-Validate-Item Trigger
- using audit in oracle database 11g
- Change Or Set Report Object Property At Run Time In Oracle Forms Using Set_Report_Object_Property Command
- Using Oracle Database 11g Release 2 Result Cache in an Oracle RAC Environment
- windows下python如何安装模块或包? How to install package or module in windows OS when using PYTHON?
- Oracle sequence increased unexpected when using in merge statement
- oracle 11g错误ora-01033:oracle initialization or shutdown in progress解决办法
- Left Outer Join using + sign in Oracle 11g
- Using Transparent Database Encryption in Oracle Database 11g
- [转]C# and the using Statement in 3 seconds and a bug in Reflector
- ORA-01033 : ORACLE initialization or shutdown in progress
- ERROR: ORA-01033: ORACLE initialization or shutdown in progress
- Zero Downtime Upgrade of Oracle 10g to Oracle 11g Using GoldenGate — 2