如果应用程序回滚该 db2 过程事务,如何将 db2 过程数据存储在 table 中?

How to store db2 procedure data in a table, if application rolls back that db2 procedure transaction?

我想知道是否有任何方法可以在 table 中存储 db2 过程数据,即使该特定过程已被应用程序回滚。

应用程序正在 table1 中执行更新语句,然后调用过程 proc1,returns 在输出游标中为 N 或 Y。当程序proc1的输出为N时,应用程序回滚事务,其中包括db2程序的运行和table1上的更新。有没有办法在中插入一条记录table_err,在过程 proc1 的 运行 期间,当应用程序由于 proc1 输出为 N 而回滚事务时?

这里使用的 db2 版本是 11.1 LUW

为此使用所谓的 autonomous 程序。
Calling procedures

An autonomous procedure is a procedure that, when called, executes inside a new transaction independent of the original transaction. When the autonomous procedure successfully completes, it will commit the work performed within the procedure, but if it is unsuccessful, the procedure rolls back any work it performed. Whatever the result of the autonomic procedure, the transaction which called the autonomic procedure is unaffected. To specify a procedure as autonomous, specify the AUTONOMOUS keyword on the CREATE PROCEDURE statement.