Postgresql 更新触发器不接受 When / OF 条件
我正在尝试编写一个触发器,但出现语法错误:
CREATE TRIGGER archive_domain_trig
AFTER UPDATE OF is_rejected ON pending_domains
FOR EACH ROW
WHEN (new.is_rejected is True)
EXECUTE PROCEDURE archive_domain_fun();
错误:“OF”处或附近的语法错误
不仅如此,而且它还在“when”条件上给出错误,例如
CREATE TRIGGER archive_domain_trig
AFTER UPDATE ON pending_domains
FOR EACH ROW
WHEN (new.is_rejected is True)
EXECUTE PROCEDURE archive_domain_fun();
给出:
错误:“WHEN”处或附近的语法错误。
select version();
"EnterpriseDB 8.3.0.116 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.0"
这几乎与 postgres 的例子类似,谁能告诉我我在这里做错了什么?
I am trying to write a trigger but getting syntax error:
CREATE TRIGGER archive_domain_trig
AFTER UPDATE OF is_rejected ON pending_domains
FOR EACH ROW
WHEN (new.is_rejected is True)
EXECUTE PROCEDURE archive_domain_fun();
ERROR: syntax error at or near "OF"
not only this but it is giving error on "when" condition also e.g.
CREATE TRIGGER archive_domain_trig
AFTER UPDATE ON pending_domains
FOR EACH ROW
WHEN (new.is_rejected is True)
EXECUTE PROCEDURE archive_domain_fun();
gives:
ERROR: syntax error at or near "WHEN".
select version();
"EnterpriseDB 8.3.0.116 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.0"
This is almost similar to postgres example, can anyone tell me what am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜测 EnterpriseDB 8.3 是 PostgreSQL 8.3 的 EnterpriseDB 版本。条件触发器(即
WHEN
选项)是 PostgreSQL 9.0 中的新功能。比较 8.3 和 9.0。I'd guess that EnterpriseDB 8.3 is the EnterpriseDB version of PostgreSQL 8.3. Conditional triggers (i.e. the
WHEN
option) are a new feature in PostgreSQL 9.0. Compare the CREATE TRIGGER documentation for 8.3 and 9.0.