Error handling Openedge事务错误处理记录不会在子事务中回滚
我有下面的代码,并试图做错误处理。但有点不对劲Error handling Openedge事务错误处理记录不会在子事务中回滚,error-handling,transactions,openedge,Error Handling,Transactions,Openedge,我有下面的代码,并试图做错误处理。但有点不对劲 Routine–level throw error. PROCEDURE Create-Subrecords : For each db-table1 no-lock : LABEL1: For each db-table2 no-lock on error undo, next LABEL1 : For each db-table3 no-lock on
Routine–level throw error.
PROCEDURE Create-Subrecords :
For each db-table1 no-lock :
LABEL1:
For each db-table2 no-lock
on error undo, next LABEL1 :
For each db-table3 no-lock
on error undo, throw:
Create db-table4.
…..
End. /* db-table3 */
Run proc1. (Do some database updates on db-table2)
Catch e as progress.lang.apperror:
Msg = e:Getmessage(1). /* save message for later */
Undo, next LABEL1.
End catch.
End. /* db-table2 */
End. /* db-table1 */
End PROCEDURE.
问题是Proc1返回一个由catch语句捕获的错误。
在这里,我想撤销在为每个db-table2启动的事务中完成的所有工作
所以我认为所有db-table4记录(在为每个db-table3启动的子事务中创建)
必须删除。=>但事实并非如此,如果我在程序完成后查看数据库,所有新的db-table4记录都在那里
我做错了什么?因为我想回滚(出错时)LABEL1中启动的所有内容
感谢您的帮助让大家都很轻松:编写正确的代码(命令应该是错误撤消、抛出时的例程级别)并且格式良好!发现,对于每个db-table2未锁定错误撤消,下一个标签1:=>此标签未启动事务。每个db-table3都启动了第一个事务,第二个事务在tjhe run proc1中。我在每个db-table2后面放了一个transaction关键字,效果很好。