Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Bulk Collect with FORALL not working - Not enough values error

175456Jan 19 2011 — edited Jan 20 2011
Hi,

I am trying to copy data from one table to another which are having different number of columns. I am doing the following. But it threw not enough values error.

Table A has more than 10 millions of records. So I am using bulk collect instead of using insert into select from.

TABLE A (has more columns - like 25)
c1 Number
c2 number
c3 varchar2
c4 varchar2
...
...
...
c25 varchar2

TABLE B (has less columns - like 7)
c1 Number
c2 number
c3 varchar2
c4 varchar2
c5 number
c7 date
c10 varchar2

declare

TYPE c IS REF CURSOR;

v_c c;

v_Sql VARCHAR2(2000);
TYPE array is table of B%ROWTYPE;
l_data array;


begin

v_Sql := 'SELECT c1, c2, c3, c4, c5, c7, c10 FROM A ORDER BY c1';

OPEN v_c FOR v_Sql;

LOOP
FETCH v_c BULK COLLECT INTO ldata LIMIT 100000;

FORALL i in 1 .. ldata.count
INSERT
INTO B
VALUES ldata(i);

END LOOP;
COMMIT;

exception
WHEN OTHERS THEN
ROLLBACK;
dbms_output.put_line('Exception Occurred' || SQLERRM);
END;


When I execute this, I am getting
PL/SQL: ORA-00947: not enough values

Any suggestions please. Thanks in advance.
This post has been answered by JustinCave on Jan 19 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2011
Added on Jan 19 2011
2 comments
474 views