gpt4 book ai didi

sql - ORA-04071 : missing BEFORE, AFTER 或 INSTEAD OF 关键字错误

转载 作者:行者123 更新时间:2023-12-02 07:38:11 25 4
gpt4 key购买 nike

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:缺少 BEFORE、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 : missing BEFORE, AFTER 或 INSTEAD OF 关键字错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14025510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com