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 syntax

Re: Trigger syntax

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Thu, 2 Aug 2001 20:59:35 +0200
Message-ID: <996778779.13809.0.pluto.d4ee154e@news.demon.nl>

"Chris" <chrisben_at_iname.com> wrote in message news:j87jmtcgh6o6fgnd9vf0mnsf6chjtvr5r4_at_4ax.com...
> (Oracle 7.3.4 for NT)
>
> I have two tables tab1 and tab2.
>
> What I want to be able to do is create a database trigger that
> increments a sequence in tab1 when a row is inserted in tab2 but only
> were there is currently no value in tab1. (There is a one to many
> relationship between tab1 and tab2).
>
> I can do it easily if I only had one table with something like:
>
> create or replace trigger foo_tg
> before insert on tab1
> for each row
> begin
> select foo_seq.nextval into :new.field from dual;
> end;
>
> but I'm stuck - not even sure if I'm going the right way about
> achieving what I need.
>
> Any advice would be greatly appreciated.
>
> regards
>
> Chris

Please clarify: how can you increment a sequence in table 1 (and obviously you need a record for that!) if the corresponding record doesn't exist? I have a feeling we're discussing lousy design here.

Regards,

Sybrand Bakker, Senior Oracle DBA Received on Thu Aug 02 2001 - 13:59:35 CDT

Original text of this message

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