Solved

Auto increment trigger, please help.

Posted on 2013-06-06
2
379 Views
Last Modified: 2013-07-03
I have a table called "u810_header" which has  a primary key of "IDIN"

I have this sequence
CREATE SEQUENCE  u810_headerseq  MINVALUE 1 MAXVALUE 99999999 INCREMENT BY 1 START WITH 1 NOCACHE  ORDER  NOCYCLE ;

Open in new window


I am trying to create a trigger on insert to increment IDIN but get these errors

Error(2,3): PL/SQL: SQL Statement ignored
Error(3,25): PLS-00302: component 'IDIN' must be declared
Error(4,3): PL/SQL: ORA-00904: : invalid identifier

Open in new window



this is the trigger code
create or replace 
trigger U810_HEADTRIG
BEFORE INSERT ON U810_HEADER
FOR EACH ROW
BEGIN
  SELECT u810_headerseq.NEXTVAL
  INTO   u810_headerseq.IDIN
  FROM   dual;
END;

Open in new window

0
Comment
Question by:FutureDBA-
  • 2
2 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 39226272
change:
INTO   u810_headerseq.IDIN

to:
into :NEW.IDIN
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39226275
Depending on your version of Oracle:

...
FOR EACH ROW
BEGIN
  :NEW.IDIN := u810_headerseq.NEXTVAL;
END;
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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
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 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.
Via a live example, show how to take different types of Oracle backups using RMAN.

910 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

18 Experts available now in Live!

Get 1:1 Help Now