Auto increment trigger, please help.

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

FutureDBA-Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
slightwv (䄆 Netminder)Connect With a Mentor Commented:
change:
INTO   u810_headerseq.IDIN

to:
into :NEW.IDIN
0
 
slightwv (䄆 Netminder) Commented:
Depending on your version of Oracle:

...
FOR EACH ROW
BEGIN
  :NEW.IDIN := u810_headerseq.NEXTVAL;
END;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.