PDA

View Full Version : Very Urgent help required !!!!!


himanshum
12-10-03, 05:28
Hi,

I was trying to select a bulk data from a table using BULK COLLECTION feature of Oracle 9i. And i was trying with this code

DECLARE
TYPE test1_tab IS TABLE OF test1%ROWTYPE;

t_tab test1_tab := test1_tab();
BEGIN
SELECT id, description
BULK COLLECT INTO t_tab
FROM test1;
END;
/
but its giving error like

ERROR at line 7:
ORA-06550: line 7, column 21:
PLS-00597: expression 'T_TAB' in the INTO list is of wrong type
ORA-06550: line 8, column 3:
PL/SQL: ORA-00904: invalid column name
ORA-06550: line 6, column 3:
PL/SQL: SQL Statement ignored

But if i try it like this..
i.e creating table of each column

DECLARE
TYPE test1_id IS TABLE OF test1.id%TYPE;
TYPE test1_desc IS TABLE OF test1.description%TYPE;

t_tab test1_tab := test1_tab();
BEGIN
SELECT id, description
BULK COLLECT INTO test1_id,test1_desc
FROM test1;
END;
/

its working fine.....

Problem is that i have to select a chunk of data from a table of 35 coloumns. Can any one help me what exactly is the problem.
I am trying this one on Oracle 9.0.1.1.1 and i copied that above code from a well known PL/SQL book.

Thanks

mohit_parab
12-13-03, 18:48
In your first example you have defined test1_tab as test1%ROWTYPE
Collections of records cannot be a target of a BULK COLLECT INTO clause.