I have a trigger in oracle. I need to convert it into SQL server. Can anyone help me. This is the trigger to be converted.
[code=oracle]
CREATE OR REPLACE TRIGGER TR_MYTRIGGER AFTER UPDATE ON TB_USER
FOR EACH ROW
DECLARE
cursor curIStl is
SELECT * FROM TB_USER WHERE CFIN_YEAR=:NEW. CFIN_YEAR AND NDEP_NO=:NEW.ND EP_NO;
rtIStl curIStl%rowtype ;
BEGIN
IF :NEW.NCANCELLED <> :OLD.NCANCELLED THEN
Open curIStl ;
Loop
Fetch curIStl into rtIStl;
exit when curIStl%notfoun d;
IF :NEW.NCANCELLED =1 AND :OLD.NCANCELLED =0 THEN
UPDATE USER_SAL SET NAMT = NAMT + rtIStl.INC WHERE DEP_CODE = rtIStl.NDEP_NO ; END IF;
End Loop;
close curIStl;
END IF;
END;[/code]
[code=oracle]
CREATE OR REPLACE TRIGGER TR_MYTRIGGER AFTER UPDATE ON TB_USER
FOR EACH ROW
DECLARE
cursor curIStl is
SELECT * FROM TB_USER WHERE CFIN_YEAR=:NEW. CFIN_YEAR AND NDEP_NO=:NEW.ND EP_NO;
rtIStl curIStl%rowtype ;
BEGIN
IF :NEW.NCANCELLED <> :OLD.NCANCELLED THEN
Open curIStl ;
Loop
Fetch curIStl into rtIStl;
exit when curIStl%notfoun d;
IF :NEW.NCANCELLED =1 AND :OLD.NCANCELLED =0 THEN
UPDATE USER_SAL SET NAMT = NAMT + rtIStl.INC WHERE DEP_CODE = rtIStl.NDEP_NO ; END IF;
End Loop;
close curIStl;
END IF;
END;[/code]
Comment