Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: One trigger operating on multipe tables .. possible ??
Hi,
A table can have many triggers, but a trigger can only fire on one table.
You will need to create a trigger for every table.
Rob Medley
medleyrk_at_iafrica.com
Jørgen Haukland wrote:
> Hello all !
>
> Thanks to You all for asking/answering and making this one of the best
> groups on the net for an Oracle newbie.
>
> My question is: How do I get my "primary_key_insert_trigger" to work on all
> the tables in my dB ?
>
> Here's my trigger:
> (I have a sequence named insert_pk)
>
> CREATE OR REPLACE TRIGGER trigger_pk
> BEFORE INSERT ON table_a, table_b, table_c -- and so on ....
> REFERENCING NEW AS n
> FOR EACH ROW
> DECLARE
> new_key INTEGER;
> BEGIN
> SELECT insert_pk.NEXTVAL INTO new_key FROM DUAL;
> :n.pk_field_on_table := new_key;
> END;
>
> As it is for now I can only get this to work on table_a. Do I have to create
> this trigger for every table ?
>
> thanks for any help !!
>
> -jh
> NORWAY
Received on Thu Nov 26 1998 - 00:00:00 CST