PL/SQL Cursor help
Hello guys,
Can't figure what's the problem, I am trying to fetch the records that I created in a previous table by this code. This is actually cursor help that i need...
SET SERVEROUTPUT ON
set verify off
DECLARE
TYPE dept_tabtype IS TABLE OF dept%ROWTYPE INDEX BY BINARY_INTEGER;
dept_table dept_tabtype;
dept_rec dept%ROWTYPE;
CURSOR cur IS SELECT * from dept;
idx binary_integer;
BEGIN
open cur;
fetch cur bulk collect into dept_table;
close cur;
DBMS_OUTPUT.PUT_LINE('ID: (DEPTNO, DEPTNAME, LOC)');
DBMS_OUTPUT.PUT_LINE('---------------------------');
idx := dept_table.FIRST();
WHILE idx IS NOT NULL LOOP
dept_rec := dept_table(idx);
DBMS_OUTPUT.PUT_LINE(idx || ': (' || dept_rec.deptno || ',' || dept_rec.dname || ',' || dept_rec.loc || ')');
idx := dept_table.NEXT(idx);
END LOOP;
END;
it gives me this error
SQL> @prog5b.sql
fetch cur bulk collect into dept_table;
*
ERROR at line 9:
ORA-06550: line 9, column 33:
PLS-00597: expression 'DEPT_TABLE' in the INTO list is of wrong type
ORA-06550: line 9, column 5:
PL/SQL: SQL Statement ignored
any idea please need help thanks
|