Solved

Auto increment trigger, please help.

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

Suggested Solutions

Title # Comments Views Activity
Oracle sql query 7 64
migration MS SQL database to Oracle 30 62
create a nested synonym 4 25
DB migration from Mssql to 12c oracle , data not loading. 3 32
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…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

831 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