mahee999
asked on
PL/SQL: ORA-00984: column not allowed here
Hi,
i have an insert statement in my procedure and i m using the cursor value in it ..
eg:
insert into sample(sid,sname) values(cursor1.sid,cursor1 .sname);
and when i try to execute the procedure it gives the error
PL/SQL: ORA-00984: column not allowed here
so what is the cause for this error.i CANNOT POST THE PROC AS IT TOO BIG. Can anyone help me with this.
Thanks
i have an insert statement in my procedure and i m using the cursor value in it ..
eg:
insert into sample(sid,sname) values(cursor1.sid,cursor1
and when i try to execute the procedure it gives the error
PL/SQL: ORA-00984: column not allowed here
so what is the cause for this error.i CANNOT POST THE PROC AS IT TOO BIG. Can anyone help me with this.
Thanks
Probably You want to insert values from record/variable, not cursor itself!
SQL> ed
Wrote file afiedt.buf
1 declare
2 cursor cr is select * from tab_test;
3 begin
4 for rec in cr loop
5 insert into tab_test(desc_id) values (cr.desc_id);
6 end loop;
7* end;
SQL> /
insert into tab_test(desc_id) values (cr.desc_id);
*
ERROR at line 5:
ORA-06550: line 5, column 43:
PLS-00225: subprogram or cursor 'CR' reference is out of scope
ORA-06550: line 5, column 46:
PL/SQL: ORA-00984: column not allowed here
ORA-06550: line 5, column 5:
PL/SQL: SQL Statement ignored
but
SQL> ed
Wrote file afiedt.buf
1 declare
2 cursor cr is select * from tab_test;
3 begin
4 for rec in cr loop
5 insert into tab_test(desc_id) values (rec.desc_id);
6 end loop;
7* end;
SQL> /
PL/SQL procedure successfully completed.
SQL> ed
Wrote file afiedt.buf
1 declare
2 cursor cr is select * from tab_test;
3 begin
4 for rec in cr loop
5 insert into tab_test(desc_id) values (cr.desc_id);
6 end loop;
7* end;
SQL> /
insert into tab_test(desc_id) values (cr.desc_id);
*
ERROR at line 5:
ORA-06550: line 5, column 43:
PLS-00225: subprogram or cursor 'CR' reference is out of scope
ORA-06550: line 5, column 46:
PL/SQL: ORA-00984: column not allowed here
ORA-06550: line 5, column 5:
PL/SQL: SQL Statement ignored
but
SQL> ed
Wrote file afiedt.buf
1 declare
2 cursor cr is select * from tab_test;
3 begin
4 for rec in cr loop
5 insert into tab_test(desc_id) values (rec.desc_id);
6 end loop;
7* end;
SQL> /
PL/SQL procedure successfully completed.
or if You use variables instead of records it would be
SQL> ed
Wrote file afiedt.buf
1 declare
2 cursor cr is select * from tab_test;
3 desc_id varchar2(30);
4 begin
5 open cr;
6 loop
7 fetch cr into desc_id;
8 exit when cr%notfound;
9 insert into tab_test(desc_id) values (desc_id);
10 end loop;
11 close cr;
12* end;
SQL> /
PL/SQL procedure successfully completed.
SQL> ed
Wrote file afiedt.buf
1 declare
2 cursor cr is select * from tab_test;
3 desc_id varchar2(30);
4 begin
5 open cr;
6 loop
7 fetch cr into desc_id;
8 exit when cr%notfound;
9 insert into tab_test(desc_id) values (desc_id);
10 end loop;
11 close cr;
12* end;
SQL> /
PL/SQL procedure successfully completed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also post the cursor loop with in which you're doing this insert