Update multiple DW data
// Cainiao code
Dw_1.update ()
Dw_2.update ()
Initial code
If dw_1.update () = 1 and dw_2.update () = 1 then
Commit;
Else
Rollback;
End if
Intermediate code
If dw_1.update () = 1 then
If dw_2.update () = 1 then
Commit;
Else
MessageBox ("prompt", "too much! ")
Rollback;
End if
Else
MessageBox ("prompt", "too much! ")
Rollback;
End if
Advanced Code
If dw_1.update () = 1 then
If dw_2.update () = 1 then
Commit;
Else
Rollback;
MessageBox ("prompt", "Drink less! ")
End if
Else
Rollback;
MessageBox ("prompt", "Drink less! ")
End if
Expert code
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 ("prompt", "not high! ")
End if
Else
Rollback;
MessageBox ("prompt", "not high! ")
End if
When multiple DW data is updated, sometimes it cannot be all successfully updated. When transaction processing is performed, multiple DW data is updated and then commit. we may find that the previous DW update is successful, but when the subsequent table fails, it seems that the commit is executed and the rollback is not performed.
The correct syntax is as follows:
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
Description: Functions of 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.
This article is from the share blog, please be sure to keep this source http://harman.blog.51cto.com/1155829/1438971