Help with Triggers
Hi guys, really hope you'll can help me with this one........
I'm having a lot of trouble with triggers in PostGres,
I had written the below trigger in Oracle :-
CREATE OR REPLACE TRIGGER PERIPHERALS_AFT_UPD AFTER UPDATE ON PERIPHERALS FOR EACH ROW
-- CHECKING FOR CHANGE OF EMPLOYEE
IF :OLD.EMPID <> :NEW.EMPID AND :OLD.EMPID IS NOT NULL THEN
SELECT NAME INTO EMP_NAME_OLD FROM EMPLOYEE
SELECT NAME INTO EMP_NAME_NEW FROM EMPLOYEE
WHERE EMPID= :NEW.EMPID;
--ADD EMPLOYEE CHANGED ENTRY TO PERIPHERAL ACTIVITY
INSERT INTO PERIPHERALACTIVITY
(PACTID, ACTIVITYDATE, DESCRIPTION, CATEGORY, PDID)
'Employee changed from ' || EMP_NAME_OLD || ' to ' || EMP_NAME_NEW, 'EmpChg', :new.PDID);
I need to rewrite the same trigger in PostGres Sql, cant figure out how to get it done. I am a newbie with pgsql, did read a bit of the documentation but it didnt help me too much..
In postgres, triggers do not contain the function, but only call functions. The procedure is mapped out in the manual.