码迷,mamicode.com
首页 > 其他好文 > 详细

多个DW进行update

时间:2014-07-16 16:24:58      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:多个dw进行update

多个DW进行update

//菜鸟代码
dw_1.Update()
dw_2.Update()
初级代码
IF dw_1.Update() = 1 And dw_2.Update() = 1 THEN
        COMMIT;
ELSE
        ROLLBACK;
END IF
中级代码
IF dw_1.Update() = 1 THEN
        IF dw_2.Update() = 1 THEN
                COMMIT;
        ELSE
                MessageBox("提示","喝多了!")
                ROLLBACK;
        END IF
ELSE
        MessageBox("提示","喝多了!")
        ROLLBACK;
END IF
高级代码
IF dw_1.Update() = 1 THEN
        IF dw_2.Update() = 1 THEN
                COMMIT;
        ELSE
                ROLLBACK;
                MessageBox("提示","少喝点!")
        END IF
ELSE
        ROLLBACK;
        MessageBox("提示","少喝点!")
END IF
专家级代码
IF dw_1.Update(True,False) = 1 THEN
        IF dw_2.Update(True,False) = 1 THEN
                dw_1.ResetUpdate()
                dw_2.ResetUpdate()
                COMMIT;
        ELSE
                ROLLBACK;
                MessageBox("提示","没喝高啊!")
        END IF
ELSE
        ROLLBACK;
        MessageBox("提示","没喝高啊!")
END IF

 

 

多个DW进行update,有时会不能全部成功update 用事务处理时,多个DW进行update后,再COMMIT.偶然会发现前面几个DW update成功,但后面的表失败时,好像执行了COMMIT,不会rollback. 

正确的写法如下: 
if dw_1.update(true, false)= 1 and dw_2.update(true, false)=1 ... then 
  commit; 
  dw_1.resetUpdate(); 
  dw_2.resetUpdate(); 
  ...
else 
  rollback; 
end if



说明:dw_restUpdate()作用

Clears the update flags in the primary and filter buffers and empties the delete buffer of a DataWindow or DataStore.

Usage :

When a row is changed, inserted, or deleted, its update flag is set, making it marked for update. By default the Update method turns these flags off. However, if you want to coordinate updates of more than one DataWindow or DataStore, you can prevent Update from clearing the flags. Then after you verify that all the updates succeeded, you can call ResetUpdate for each DataWindow to clear the flags. If one of the updates failed, you can keep the update flags, prompt the user to fix the problem, and try the updates again.

    You can find out which rows are marked for update with the GetItemStatus method. If a row is in the delete buffer or if it is in the primary or filter buffer and has NewModified! or DataModified! status, its update flag is set. After update flags are cleared, all rows have the status NotModified! or New! and the delete buffer is empty.


本文出自 “share” 博客,请务必保留此出处http://harman.blog.51cto.com/1155829/1438971

多个DW进行update,布布扣,bubuko.com

多个DW进行update

标签:多个dw进行update

原文地址:http://harman.blog.51cto.com/1155829/1438971

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!