“引用旧的”和“引用旧的”有什么区别? & “引用新的”在 SQL 存储过程中?
我不确定这个语法是否是 Informix 特定的,但我在创建触发器时遇到了麻烦,直到我发现一些语法包含以下一行或两行:
CREATE TRIGGER accuplacer_trig
UPDATE OF processed
ON accuplacer_rec
REFERENCING OLD AS proc_pre_upd
FOR EACH ROW (EXECUTE PROCEDURE accuplacer_proc(proc_pre_upd.exam_num));
有时它被写为 REFERENCING OLD AS alias1, NEW AS alias2
REFERENCING OLD AS
和 REFERENCING NEW AS
之间有什么区别,它们的作用是什么/为什么需要它们?
I'm not sure if this syntax is Informix-specific, but I was having trouble creating a trigger until I found some syntax that included one, or both, of these lines:
CREATE TRIGGER accuplacer_trig
UPDATE OF processed
ON accuplacer_rec
REFERENCING OLD AS proc_pre_upd
FOR EACH ROW (EXECUTE PROCEDURE accuplacer_proc(proc_pre_upd.exam_num));
Sometimes it's written as REFERENCING OLD AS alias1, NEW AS alias2
What is the difference between REFERENCING OLD AS
and REFERENCING NEW AS
, and what do they do/why are they needed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“OLD”是更新之前该行中的数据。 “NEW”是更新完成后该行中的数据。如果您希望触发器根据此信息采取行动,您需要访问此信息;通常,您确实想要这个,尽管并非总是如此。
本页对在 Informix 上下文中使用触发器的这一方面进行了更详细的讨论:
http://www.pacs .tju.edu/informix/answers/english/docs/dbdk/infoshelf/sqlt/15.fm3.html
"OLD" is the data that was in the row before the update. "NEW" is the data that will be in the row after the update is complete. You need to access this information if you want your trigger to act based on it; usually, you do want this, although not always.
This page has a more lengthy discussion of using this aspect of triggers in the context of Informix:
http://www.pacs.tju.edu/informix/answers/english/docs/dbdk/infoshelf/sqlt/15.fm3.html
这是触发器发生之前和之后的值;如下所述。
It's the values before and after the trigger has occurred; as outlined below.