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: SEQUENCE values as default...

Re: SEQUENCE values as default...

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Wed, 07 Oct 1998 14:14:54 GMT
Message-ID: <361d7601.2955920@dcsun4.us.oracle.com>


On Wed, 07 Oct 1998 11:49:19 +1000, Jeremy Burton <jpburton_at_netspace.net.au> wrote:

>Hi there,
> Have what is quite possibly a frequently asked question
>about sequence numbers (although I can find nothing about it in the
>documentation or one or two books I have here). Basically, I am trying
>to use a sequence number to uniquly identify every row in a table. Given
>the way in which i am programming this stuff, it is not really feasible
>to use "insert into mytable values (myseq.nextval, blah blah)"... So I
>am wondering if there is a way to use the next value as a default, or
>failing that, do I need to use triggers or something similar for this?
>

You need to use a before insert trigger on the table.

eg.

create or replace
trigger bi_fer_foo
before insert on foo
for each row
begin
  select myseq.nextval
    into :new.col1
    from dual;
end;
/

chris.

>Thanks
>
>Jeremy Burton
Received on Wed Oct 07 1998 - 09:14:54 CDT

Original text of this message

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