[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2006-07-19
4
Medium Priority
?
2,133 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

656 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