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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Trigger help

Re: Trigger help

From: Mark Framness <framnesso_at_my-deja.com>
Date: Wed, 09 Feb 2000 19:58:22 GMT
Message-ID: <87sgsp$rss$1@nnrp1.deja.com>


In article <87o239$mei$1_at_nnrp1.deja.com>,   Jonus <jonus123_at_yahoo.com> wrote:
>
>
> I have two tables. The cus_identi_number in customer
> references cus_idnti_number in docket. Do I have to
> create a trigger so that the information entered in
> cus_identi_number of customer is also entered in the
> cus_idnti_number column of the docket table? Or does
> oracle enter the information for you.
>
> I was thinking if this trigger would do the trick:
>
> CREATE OR REPLACE TRIGGER cascade_cus_i
> AFTER INSERT ON CUSTOMER
> FOR EACH ROW
> DECLARE
> v_customer_id customer.customer_id%TYPE;
> BEGIN
> SELECT customer_id
> INTO v_customer_id
> FROM customer
> WHERE customer_id = :new.customer_id;

If I understand the concept of "mutating tables" correctly than the trigger you are trying to do above will NOT work. You can only reference the table (if the trigger is tripped via insert, update or delete statement) that the row trigger is attached to via old or new keywords and then only on the particular row referenced.

Also you do not need the v_customer_id variable instead you may write directly:
INSERT INTO docket (cus_identi_number)
VALUES (:new.customer_id);

>
> INSERT into docket
> (cus_identi_number)
> VALUES
> (v_customer_id);

--
From: Mark Framness
http://netnet.net/~farmer/index.html
All standard disclaimers apply anyone who say otherwise is itching for a fight!

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Feb 09 2000 - 13:58:22 CST

Original text of this message

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