Solved

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

Posted on 2006-11-07
5
964 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle encryption 12 69
error in oracle form 11 48
Errror when importing data from Oracle to SQL 6 62
how to use l_instance in the host command 7 34
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…
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.  …
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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.

738 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