Updating multiple rows of the same table in a trigger
802484Oct 20 2010 — edited Oct 20 2010Hello All,
I am facing a situation, in which I need to update multiple rows of a same table in which trigger has been written. IS it possbile to do it?
I know that we can use :NEW to update current row, but when we need to update multiple rows on some condtion, it fails.
Thanks in advance for any help.
CREATE OR REPLACE TRIGGER stsc.dfutoskuallocfactor_trig
BEFORE UPDATE
ON stsc.dfutosku
FOR EACH ROW
DECLARE
v_dmdunit CHAR (30);
v_dmdgroup CHAR (30);
v_loc CHAR (30);
BEGIN
--dfutosku
INSERT INTO igpmgr.dfutosku_upd_rec
VALUES (:OLD.dmdunit, :OLD.dmdgroup, :OLD.dfuloc);
--FOR rec IN (SELECT DISTINCT dmdunit, dmdgroup, dfuloc, eff, disc
-- FROM stsc.dfutosku_upd_rec)
--LOOP
-- IF (rec.eff <> '01-Jan-1970' OR rec.eff >= SYSDATE)
-- THEN
-- DBMS_OUTPUT.put_line ('STAGE3 ' || ' ' || rec.eff);
v_dmdunit := 'PLY 4-000';
v_dmdgroup := 'TRD';
v_loc := '48441';
IF (v_dmdunit = 'PLY 4-000' AND v_dmdgroup = 'TRD' AND v_loc = '48441')
THEN
:NEW.udc_error := 1;
END IF;
--igpmgr.
pkg_updateAllocfactor.allocfactor_update(o_return_code OUT NOCOPY PLS_INTEGER);
--END IF;
-- END LOOP;
END;
/
With Regards,
SK