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: Insert if not exists?

Re: Trigger: Insert if not exists?

From: FC <flavio_at_tin.it>
Date: Tue, 10 Dec 2002 20:01:51 GMT
Message-ID: <PKrJ9.2255$ab2.65876@news1.tin.it>


Hello Barry,
I'd suggest you to put a referential constraint on the title_word table (in this case a primary key) and then trap any error of the kind DUP_VAL_ON_INDEX inside the trigger, that is wrapping up the INSERT statement:

create or replace trigger <my_trigger>
... bla bla bla ...

begin

   ...
   begin

     INSERT INTO title_words
          bla bla bla;

   exception
   when DUP_VAL_ON_INDEX then

        null;
   when others then raise;
   end;
...
end;

It looks simple to me, but to you ?

Bye,
Flavio

"Barry Prentiss" <thebear_at_NOSPAM.stanford.edu> wrote in message news:at5fqr$erd$1_at_news.Stanford.EDU...
> Hi,
> I am trying to devise a trigger that inserts an object_id and a list of
the
> object's title_words into a title_words table. I would like to avoid
> duplicate rows by ensuring that, even if the same title_word occurs many
> times, only one insert for that object_id/title_word pair will occur. Is
> there a simple way to do this?
> [Oracle 8i, PL/SQL]
> Thx in Advance,
> Barry Prentiss
> Stanford University
>
>
Received on Tue Dec 10 2002 - 14:01:51 CST

Original text of this message

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