I am porting a database structure from Oracle to SQL Server 2000. I have managed to get all of the data and most of the constraints and triggers ported to the new database. However, I am uncertain of how to port a trigger with conditional statements in it to SQL Server 2000 from Oracle. I have the following statement in Oracle. I want to change the status of one field based on the values of two other fields, one which is the new value and the other is the value before the update. The Oracle trigger code follows. I currently have the trigger properly updating the MODIFY_DATE and MODIFY_BY fields. I just cannot find how to perform the conditional statement in SQL Server 2000. Thanks in advance for any assitance.
CREATE OR REPLACE TRIGGER "SCHEMA".BEF_UPDATE_TABLENAME
BEFORE UPDATE
ON TABLENAME
FOR EACH ROW
-- PL/SQL Block
DECLARE
USERVAR VARCHAR2(20);
BEGIN
SELECT USER INTO USERVAR FROM DUAL;
:NEW.MODIFY_DATE := SYSDATE;
:NEW.MODIFY_BY := USERVAR;
if :new.modify_date < '30-aug-2001' then
begin
if :new.REGISTRATION_STATUS = 'Cancel' then
:new.refund_paid := ld.price - 100;
end if;
end;
else
:new.refund_paid := '';
end if;
END ;
CREATE OR REPLACE TRIGGER "SCHEMA".BEF_UPDATE_TABLENAME
BEFORE UPDATE
ON TABLENAME
FOR EACH ROW
-- PL/SQL Block
DECLARE
USERVAR VARCHAR2(20);
BEGIN
SELECT USER INTO USERVAR FROM DUAL;
:NEW.MODIFY_DATE := SYSDATE;
:NEW.MODIFY_BY := USERVAR;
if :new.modify_date < '30-aug-2001' then
begin
if :new.REGISTRATION_STATUS = 'Cancel' then
:new.refund_paid := ld.price - 100;
end if;
end;
else
:new.refund_paid := '';
end if;
END ;