for ll_rowno= dw_detail.rowcount() to 1 step -1
dwstatus = dw_detail.getitemstatus(ll_rowno,0,primary!)
ls_wlbm =dw_detail.getitemstring(ll_rowno,"wlbm")
ls_wlname =dw_detail.getitemstring(ll_rowno,"wlname")
if ls_wlbm='' or isnull(ls_wlbm) or ls_wlname='' or isnull(ls_wlname) then
dw_detail.deleterow(ll_rowno)
continue
end if
select count(*) into :li_count from wlk_bm where wlbm=:ls_wlbm;
if li_count =0 then
messagebox(mt,"<物料編碼>中無此編碼:"+ls_wlbm+",請核對.",stopsign!,ok!)
rollback;
ii_result = -1
return
end if
// ldec_oldqty[ll_rowno]=dw_detail.getitemdecimal(ll_rowno,"wlqty",primary!,true)//修改前
ldec_newqty[ll_rowno]=dw_detail.getitemdecimal(ll_rowno,"wlqty",primary!,false)//修改后
choose case dwstatus
case new!,notmodified!
continue
case newmodified!
dw_master.iuv_linkage.uf_set_pkey(ll_rowno)
update wlk_acc_bill set instock=instock + :ldec_newqty[ll_rowno],modifydate = getdate() where wlbm=:ls_wlbm and wlpostion=:gs_depotno;
if sqlca.sqlnrows=0 then
rollback;
messagebox(mt,"更新庫存失敗!")
ii_result = -1
return -1
case datamodified!
////
end choose
next
end if
//
/*-------------------------------------------------------------------------------*/
IF dw_master.Update(true,false)=1 then
if dw_detail.update() = 1 THEN
--測驗在此,rollback后,update 的資料還是更新,沒回滾?
rollback; //test
if SQLCA.AutoCommit = False then
messagebox(mt,"false")
else
messagebox(mt,"true")
end if //提示 sqlca.autocommit = false
//Commit;
dw_master.resetupdate()
//dw_detail.resetupdate()
Open(w_success)
ii_result = 1
wf_set_button_e("AEDP23X")
this.triggerevent("ue_closeedit")
ii_recorder_status=0
RETURN 1
ELSE
Rollback;
MessageBox("提 示","保存資料失敗!"+sqlca.sqlerrtext)
ii_result = -1
RETURN -1
END IF
else
Rollback;
MessageBox("提 示","保存資料失敗!"+sqlca.sqlerrtext)
ii_result = -1
RETURN -1
END IF
---
請各位同行幫我找找問題.不勝感謝!
uj5u.com熱心網友回復:
看一下sqlca.AutoCommit是不是設定為true了在第一行設定一下sqlca.autocommit = false,然后再試試
uj5u.com熱心網友回復:
發貼時,如果有較長的代碼,可以選擇格式成源代碼,更易看清。uj5u.com熱心網友回復:
dw_master和dw_detail都沒有rollback嗎?uj5u.com熱心網友回復:
sqlca.autocommit = false 這個沒有錯,rollback后dw_master\dw_detail是沒有將資料保存到資料庫中這個是正確的,但更新庫存的update 陳述句執行卻沒能回滾,謝謝上面的回復.問題還未解決.uj5u.com熱心網友回復:
你的uf_set_pkey函式是干什么的?應該有其它地方進行了提交了;用SQL的跟蹤分析器跟蹤一下,看update陳述句在rollback之間有無commit或DDL或DCL之類的sql操作;
uj5u.com熱心網友回復:
這就說明在呼叫dw.update()之前,肯定有執行過commit, 看看資料視窗的updatestart事件中有沒有commit,或者完整的斷點跟蹤除錯一下,看看在update陳述句之后,dw.update()之前是否有commit陳述句被執行
uj5u.com熱心網友回復:
Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is NULL, Update returns NULL. If there is no DataWindow object assigned to the DataWindow control or DataStore, this method returns 1.=1為啥回滾,樓主幾個片段都很奇怪的
select count(*) into :li_count from wlk_bm where wlbm=:ls_wlbm;
if li_count =0 then
messagebox(mt,"<物料編碼>中無此編碼:"+ls_wlbm+",請核對.",stopsign!,ok!)
rollback;
ii_result = -1
return
end if
if sqlca.sqlnrows=0 then
uj5u.com熱心網友回復:
逐行debug,涉及到資料庫操作時檢查sqlca的屬性值sqlcode,就可以找到具體是在哪一行代碼被提交掉了uj5u.com熱心網友回復:
試試加入一句dw_detail.Accepttext(),能不能是資料視窗未接受更新的資料??uj5u.com熱心網友回復:
不是一個事務吧uj5u.com熱心網友回復:
pb debug 和sql server profile 同時使用啊轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/78053.html
標籤:數據庫相關
