Solved

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

Posted on 2006-11-07
5
946 Views
Last Modified: 2012-05-05
DECLARE CURSOR cur_locmetreading IS
select item.itemnum as a, item.recond AS b, MATUSETRANS.STORELOC AS c, to_char(MATUSETRANS.transdate, 'MM') AS d,
sum(MATUSETRANS.QUANTITY) as f from item, matusetrans
where item.itemnum=matusetrans.itemnum
and matusetrans.transdate > to_date('20050901', 'YYYYMMDD')
and matusetrans.transdate < to_date('20051001','YYYYMMDD')
group by item.itemnum, item.recond, MATUSETRANS.STORELOC, to_char(MATUSETRANS.transdate, 'MM')
order by item.itemnum;


BEGIN

 DBMS_OUTPUT.PUT_LINE ('START!');

 FOR c_locmetreading IN cur_locmetreading LOOP


  BEGIN
  INSERT INTO INV_TEMP
  VALUES(cur_locmeterreading.a,
  cur_locmeterreading.b,
  cur_locmeterreading.c,
  cur_locmeterreading.d,
  cur_locmeterreading.f);
  commit;
 

  EXCEPTION
   WHEN too_many_rows THEN
   DBMS_OUTPUT.PUT_LINE ('Too many ');

   WHEN OTHERS THEN
   DBMS_OUTPUT.PUT_LINE ('Err: '|| SQLERRM);
  END;

 END LOOP;

 DBMS_OUTPUT.PUT_LINE ('END!');

EXCEPTION
 WHEN OTHERS THEN
 DBMS_OUTPUT.PUT_LINE ('Err: '|| SQLERRM);

END;
/

SQL> desc inv_temp;
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- ------------------------------------
 STOCKCODE                                                      VARCHAR2(20 CHAR)
 RECOND                                                         NUMBER
 STOREROOM                                                      VARCHAR2(15 CHAR)
 MONTH                                                          VARCHAR2(3 CHAR)
 QUANTITY                                                       NUMBER

I am having ORA-00984: column not allowed here when i run the procedure against inv_temp. I even tried adding to_number cur_locmeterreading.b, cur_locmeterreading.f. And it fails. Anyone can help?? Thank in advance
0
Comment
Question by:baihao
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
lappins earned 50 total points
ID: 17891238
You are specifying the cursor object instead of the record objects: Try:

  INSERT INTO INV_TEMP (stockcode, recond, storeroom, month, quantity)
  VALUES(c_locmeterreading.a,
  c_locmeterreading.b,
  c_locmeterreading.c,
  c_locmeterreading.d,
  c_locmeterreading.f);
0
 
LVL 31

Assisted Solution

by:awking00
awking00 earned 50 total points
ID: 17891812
cursor says locmetreading
values say locmeterreading
0
 
LVL 31

Expert Comment

by:awking00
ID: 17891834
Also, values should be c_locmetreading, not cur_locmetreading.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20296237
Forced accept.

Computer101
EE Admin
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now