“引用旧的”和“引用旧的”有什么区别? & “引用新的”在 SQL 存储过程中?

发布于 2024-12-03 12:07:59 字数 477 浏览 3 评论 0原文

我不确定这个语法是否是 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 ASREFERENCING 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

第七度阳光i 2024-12-10 12:07:59

“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

蓝眸 2024-12-10 12:07:59

这是触发器发生之前和之后的值;如下所述。

许多触发的 SQL 语句需要引用当前的数据
被导致它们触发的数据库事件更改。这
触发的 SQL 语句可能需要引用新的(更改后或
“之后”)值。

...更改的数据可以参考
使用转换变量或转换的触发 SQL 语句
表。引用子句允许您提供相关性
通过指定 OLD/NEW AS 来指定这些转换变量的名称或别名
相关性名称。

It's the values before and after the trigger has occurred; as outlined below.

Many triggered-SQL-statements need to refer to data that is currently
being changed by the database event that caused them to fire. The
triggered-SQL-statement might need to refer to the new (post-change or
"after") values.

...Changed data can be referred to in the
triggered-SQL-statement using transition variables or transition
tables. The referencing clause allows you to provide a correlation
name or alias for these transition variables by specifying OLD/NEW AS
correlation-Name .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文