在更新Firebird上触发 [英] Trigger on Update Firebird
本文介绍了在更新Firebird上触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每当更新字段 sync
而没有标记 YES
时,我需要将该字段设置为 NULL
。
Whenever the field sync
is updated without the flag being YES
I need to set that field to NULL
.
CREATE TRIGGER my_trigger FOR customers
AFTER UPDATE
as
BEGIN
if(new.sync <> 'YES')
then new.sync = NULL;
end
但我一直收到错误:
动态SQL错误SQL错误代码= -104意外的命令结束-
第6行,第26列
Dynamic SQL Error SQL error code = -104 Unexpected end of command - line 6, column 26
我相信第6行是 then new.sync = NULL
吗?我认为问题可能出在;
的使用上,但事实并非如此,因为如果我删除它,则会出现相同的错误,但在第7行 。
I believe line 6 is then new.sync = NULL
? I thought the problem might be the use of ;
but it's not, because if I remove it then it gives the same error but in the line 7.
推荐答案
已解决。
缺少了一些代码,但除此之外,还有逻辑。我需要使用之前
而不是之后
。
Some code was missing but besides that also the logic. I needed to used BEFORE
and not AFTER
.
SET TERM !;
CREATE TRIGGER my_trigger FOR customers
BEFORE UPDATE
POSITION 0
AS BEGIN
IF(new.sync <> 'YES') THEN BEGIN
new.sync = NULL;
END
END;
这篇关于在更新Firebird上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文