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 -> Need help with triggers!!!

Need help with triggers!!!

From: Norman Dunbar <Norman.Dunbar_at_lfs.co.uk>
Date: Tue, 20 Aug 2002 17:14:23 +0100
Message-ID: <E2F6A70FE45242488C865C3BC1245DA702883C2E@lnewton.leeds.lfs.co.uk>


Check out the PL/SQL developer's guide for info, but ........

Why would you want to write a trigger that updates an employee's pay every time the row was updated in the table ?

Lets say you have this :

create or replace trigger west_employee_bu before update on west_employee
for each row
begin

        :new.PayRate := :old.PayRate * 1.15;
end;
/

So, using the example you have supplied, If a woman gets married and changes her name, the following would be done :

update west_employee set surname = 'THINGY' where employee_id = 'whatever';

and this would automatically give the new Mrs Thingy a 15% pay rise and all because she changed her name !
Every single update to any row in the table will fire the trigger and give the employee in question a 15% pay rise.

The other problem I have is this 'show the old and new pay rate' - not in a trigger you don't :o)

Do you want to write a procedure or function rather than a trigger ? Do you know the difference ?
Are you sure it is an Oracle question ? :o)

Cheers,
Norman.



Norman Dunbar
Database/Unix administrator
Lynx Financial Systems Ltd.
mailto:Norman.Dunbar_at_LFS.co.uk
Tel: 0113 289 6265
Fax: 0113 289 3146
URL: http://www.Lynx-FS.com

-------------------------------------

-----Original Message-----
From: kwest [mailto:kwest]On Behalf Of kwest Posted At: Tuesday, August 20, 2002 4:06 PM Posted To: server
Conversation: Need help with triggers!!! Subject: Need help with triggers!!!

I need help writing a trigger. The directions are to create a BEFORE TRIGGER on your employee table (west_employee). Update the table by increasing the payrate of all your employees by 15%. The trigger should fire once for each row that is updated. Show the old and new pay rate.

Here's what I have so far:

create or replace trigger west_bi before insert on west_employee for each row declare v_pay_rate west.pay_rate%type; begin

I'd appreciate any help I can get. Thanks, Kim Received on Tue Aug 20 2002 - 11:14:23 CDT

Original text of this message

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