多個DW進行updateide
//菜鳥代碼
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 IFspa
多個DW進行update,有時會不能所有成功update 用事務處理時,多個DW進行update後,再COMMIT.偶然會發現前面幾個DW update成功,但後面的表失敗時,好像執行了COMMIT,不會rollback.
rest
正確的寫法以下:
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 iform
說明:dw_restUpdate()做用事務
Clears the update flags in the primary and filter buffers and empties the delete buffer of a DataWindow or DataStore.it
Usage :event
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.class
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.date