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: trigger question

Re: trigger question

From: Chuck Hamilton <chuck_hamilton_at_yahoo.com>
Date: Fri, 21 Sep 2001 16:02:29 -0400
Message-ID: <9og6cj$da3o9$1@ID-85580.news.dfncis.de>


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Marek Budyn" <rayn_at_infostrade.com.pl> wrote in message news:9og61p$5oe$1_at_news.tpi.pl...
> Hi!
> Could someone tell me, how to write a trigger that updates index of
> a new row in table with next sequence number, please ?
> I mean, that i have a table, a sequence, and I want to create a
> trigger, that fires when I add a new row to this table and updates
> index column in added row (like autonumber or serial type in other
> databases)
>
> thanks for help
>
> Marek Budyn

CREATE OR REPLACE TRIGGER seq_trigger
BEFORE INSERT
ON mytable
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
begin
if ( :new.id is null ) then
  SELECT CONTACT_MASTER_PK_SEQ.nextval
  INTO :new.id
  FROM dual;
end if;
end;

/

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBO6uc0Gm5A4kkb4ZsEQKEBwCfbiqYbz2vVlzhT7gg/unfMlIdUEsAn22Z 9659r4F+Yy7T5KY/yQ/J9er+
=m2Jk
-----END PGP SIGNATURE----- Received on Fri Sep 21 2001 - 15:02:29 CDT

Original text of this message

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