获取受更新影响的行 [英] Get rows affected by an update

查看:72
本文介绍了获取受更新影响的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在AS400上的DB2中获得受SQL UPDATE语句影响的确切行

查看哪些是非常有用的

我看到了:相同,但特定于MySQL。是否有标准的SQL方式或特定于DB2的方式?

I saw this question: is the same, but specific for MySQL. Is there a standard SQL way or DB2 specific way for doing this?

我也看到了此技术,但由于我的更新查询过于复杂,因此无法使用。

I saw also this technique, but I can't use it because my update query is too much complicated.

附加功能可能是:还获取这些行的先前版本,因此您可以将其与实际版本进行比较(更新后),并查看

An additional feature could be: getting also previous version of these rows, so you can compare it with the actual version (after the update) and see the modifications.

编辑:我的 DB2版本是IBM i V5R3和V6R1的版本。

my DB2 versions are the ones for IBM i V5R3 and V6R1

推荐答案

您没有说运行的是哪个版本的i5 / OS,但是如果运行的是V6R1或更高版本,则可以使用数据更改表引用查看行由update语句修改的内容。例如:

You don't say what version of i5/OS you are running, but if you are running V6R1 or later, you can use "data change table references" to see the rows that are modified by the update statement. For example:

select * from FINAL TABLE ( update yourtable set c1 = x where ... )

最终表将在触发所有触发器后为您提供行。请注意,还有另一个数据更改表引用,NEW TABLE-将在行受任何触发器影响之前显示行。

FINAL TABLE will give you the rows after any/all triggers are fired. Please note there are also another data change table references, NEW TABLE - which will show the rows before they are affected by any triggers.

您可以阅读有关数据更改表引用的信息。在 i5 / OS文档中。

You can read about data change table references in the i5/OS documentation.

这篇关于获取受更新影响的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆