?
Solved

Auto increment trigger, please help.

Posted on 2013-06-06
2
Medium Priority
?
384 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-
[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
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses

762 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