Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: sequences

Re: sequences

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: 24 Aug 1998 03:38:43 GMT
Message-ID: <35efde84.25708652@netnews.worldnet.att.net>


On Sun, 23 Aug 1998 14:20:01 -0400, "bubba" <brittonb_at_webt.com> wrote:

>However, I have an issue where we are using Access 97 to update some data.
>
>How can I set a trigger so that oracle automatically inserts the next value
>into the primary key?

The following trigger should do it. In this example, fld_pk is the column name that gets the sequence.

regards,

Jonathan Gennick

create or replace trigger my_table_set_key

        before insert on my_table
        referencing new as n
        for each row

declare
new_key integer;
begin
  select key_for_table.nextval into new_key from dual;   :n.fld_pk := new_key;
end;
/ Received on Sun Aug 23 1998 - 22:38:43 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US