CREATE TRIGGER TRG_LOADMONEY
ON KIOSK
AFTER INSERT
AS
DECLARE @LOADEDCARDID INT
DECLARE @LOADEDAMOUNT INT
SELECT @LOADEDCARDID = LOADEDCARDID, @LOADEDAMOUNT = LOADEDAMOUNT FROM INSERTED
UPGRADE CARD SET CHARGE = CHARGE + @LOADEDAMOUNT
WHERE CARDID = @LOADEDCARDID
我运行了这段代码,但出现错误“ORA-04071:缺少关键字BEEFORE,AFTER或INSTEAD OF”。我有AFTER声明,我不明白这是什么问题。
最佳答案
您使用的语法适用于sql server。
尝试这个:
CREATE OR REPLACE TRIGGER TRG_LOADMONEY
AFTER INSERT
ON KIOSK FOR EACH ROW
/*
These variables are not required because Oracle triggers can reference the table's
columns directly using the :OLD and :NEW prefixes.
DECLARE
LOADEDCARDID PLS_INTEGER;
LOADEDAMOUNT PLS_INTEGER;
*/
BEGIN
UPDATE CARD
SET CHARGE = CHARGE + :NEW.LOADEDAMOUNT
WHERE CARDID = :NEW.LOADEDCARDID;
END;
关于sql - ORA-04071:缺少关键字BEEF之前,之后或INSTEAD OF错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14025510/