Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: triger begginer
rk wrote:
> Hi
> Well I'm trying to make simple trigger, when updating
> tableA.qty I just want to calculate with record from tableB.price and record
> from tableA.qty and write result in tableA.amount.
>
> PROMPT Creating Trigger 'IZRACUN_IZPLACILA'
> CREATE OR REPLACE TRIGGER Calculate_amount
> AFTER UPDATE OF QTY
> ON TABLE_A
> FOR EACH ROW
> WHEN (NOT(new.QTY = old.QTY)
>
> DECLARE
> pPRICE NUMBER;
>
> -- PL/SQL Block
> BEGIN
> IF updating THEN
>
> --this I think it works - just getting value from
> --TABLE_B.price
> SELECT price INTO pPRICE
> FROM TABLE_B, TABLE_C
> WHERE TABLE_C.idC = :old.C_id
> AND TABLE_C.B_id=TABLE_B.idB;
>
> -- declaring problem ???
> :new.amount := :new.QTY * pPRICE;
>
> END IF; -- updating
> END;
>
> Thx a lot
> RK
What is the point of: "IF updating THEN"?
It is an AFTER UPDATE trigger ... what else is it going to do?
-- Daniel Morgan http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp damorgan_at_x.washington.edu (replace 'x' with a 'u' to reply)Received on Wed Apr 07 2004 - 00:22:29 CDT