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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Need help w/ a trigger

Re: Need help w/ a trigger

From: DriftWood <drift_wood_at_my-deja.com>
Date: 2000/02/16
Message-ID: <88eh0d$dg6$1@nnrp1.deja.com>#1/1

You needn't store the version number elsewhere if you are wiling to let the sequence value represent the version of the table. Here is a simple trigger using a sequence to populate a PK field:

create table foo (SEQ number, DATA varchar2);

and now a sequence:

create sequence foo_idx;

and now a trigger for the table:

create or replace trigger foo_seq_ins
before insert on foo
for each row
begin
select foo_idx.nextval into :new.seq from dual; end;

now a SQL statement such as:
INSERT INTO FOO (DATA) VALUES ('TEST'); will automatically generate the SEQ column for you...

--
-cheers

  DW



"It is a kind of good deed to say well; and yet words are not deeds.   -William Shakespeare"

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Feb 16 2000 - 00:00:00 CST

Original text of this message

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