سؤال

How can I rewrite for SQL Server a trigger that was originally written for Oracle ?

Here is my Oracle trigger code:

CREATE OR REPLACE TRIGGER P000KUL_TEST
BEFORE
INSERT
ON P000KUL
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
SELECT TO_CHAR(SYSDATE, 'dd/mm/RRRR') INTO :NEW.SYSTEM_DATE FROM DUAL;
SELECT TO_CHAR(SYSDATE, 'hh:mi') INTO :NEW.SYSTEM_TIME FROM DUAL;
END; 
هل كانت مفيدة؟

المحلول

You can use trigger like this:

CREATE TRIGGER tr_P000KUL_INSERT
ON P000KUL
    FOR INSERT
    AS
    update inserted 
    set system_date = convert(varchar, getdate(), 103), 
        system_time = convert(varchar, getdate(), 108);
go
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى dba.stackexchange
scroll top