Insert Trigger
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Insert Trigger

  1. #1
    Join Date
    Aug 2000
    Location
    Straham NH
    Posts
    73

    Insert Trigger

    I know this should be simple but I'm lost.

    I want to create a trigger that will fire before insert on a table to get the next sequence value for the primarykey of the table:

    create or replace trigger wells_ins_row
    before insert on Wells
    for each row
    begin
    WellID := wellsid_seq.nextval;
    end;
    /


    The table is name Wells and the column WellID is the PK for the table. There is a wellsid_seq created to get the sequence number from.

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Code:
    create or replace trigger wells_ins_row
    before insert on Wells
    for each row
    begin
    select wellsid_seq.nextval into :new.WellID from dual;
    end;
    /
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    Sep 2005
    Posts
    6
    I am not sure what is the issue you are facing. But, try something like this:
    select wellsid_seq.nextval into WellID from dual;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width