Solved

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

Posted on 2006-11-07
5
957 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:
Stephen Lappin 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 32

Assisted Solution

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I rollback insert statements after commit in oracle? 7 221
oracle 11g 23 106
su - oracle could not open session 6 95
PL/SQL: ORA-00979: not a GROUP BY expression 3 26
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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
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.

765 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