如何为SQL Server重写为Oracle编写的触发器?


9

如何为SQL Server重写最初为Oracle编写的触发器?

这是我的Oracle触发代码:

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; 

Answers:


6

您可以像这样使用触发器:

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
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.