Solved

Auto increment trigger, please help.

Posted on 2013-06-06
2
382 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 77

Accepted Solution

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

to:
into :NEW.IDIN
0
 
LVL 77

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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 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.

726 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