Hi ,
I have the following code for dept table which has 4 rows if I use the code EXIT WHEN cursor%notfound the cursor is exiting immediately without fetching single row .
is this behavior expected ??
here is the Plsql code
DECLARE
CURSOR cur_dept IS SELECT * FROM dept;
v_cur_dept cur_dept%ROWTYPE;
TYPE t_dept IS TABLE OF dept%ROWTYPE index by BINARY_INTEGER ;
v_t_dept t_dept;
The current Oracle Version I am using is
BEGIN
OPEN cur_dept;
DBMS_OUTPUT.PUT_LINE('DEPTNO DNAME LOC');
LOOP
FETCH cur_dept BULK COLLECT INTO v_t_dept limit 1;
EXIT WHEN cur_dept%NOTFOUND ;
DBMS_OUTPUT.PUT_LINE(v_cur_dept.deptno||' '||v_cur_dept.dname||' '||v_cur_dept.loc);
END LOOP;
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
"CORE 11.1.0.6.0 Production"
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
Sample Scripts ..
Insert into DEPT (DEPTNO,DNAME,LOC) values (10,'ACCOUNTING','NEW YORK');
Insert into DEPT (DEPTNO,DNAME,LOC) values (20,'RESEARCH','DALLAS');
Insert into DEPT (DEPTNO,DNAME,LOC) values (30,'SALES','CHICAGO');
Insert into DEPT (DEPTNO,DNAME,LOC) values (40,'OPERATIONS','BOSTON');
Thanks in advance ..will appreciate any thoughts on this .
END;