?
Solved

PL/SQL: ORA-00984: column not allowed here

Posted on 2006-07-19
4
Medium Priority
?
2,072 Views
Last Modified: 2009-06-11
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
0
Comment
Question by:mahee999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Expert Comment

by:sathyagiri
ID: 17138598
Are you using EXECUTE immediate to do this?

Also post the cursor loop with in which you're doing this insert
0
 
LVL 14

Expert Comment

by:GGuzdziol
ID: 17138612
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.
0
 
LVL 14

Expert Comment

by:GGuzdziol
ID: 17138629
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.
0
 
LVL 16

Accepted Solution

by:
MohanKNair earned 750 total points
ID: 17139470
"column not allowed here" error comes when the values of insert statement has any column name of the table. insert into sample(sid,sname) values(sid,name); --- this will give error

Post the PL/SQL or SQL code
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question