dim dbmaster as database
dim wsmaster as workspace
dim qrytemp1 as QueryDef
dim qrytemp2 as QueryDef
dim sql1 as String
dim sql2 as String
dim lCommit as boolean
' dbmaster 和 wsmaster 巳設定好了
' 資料表有 nstock , stock;
' 它們的Structure 是相同的;
' sql1 = 以下是想把資料表 nstock 內 Shop1 6月份的所有資料搬到資料表 stock;
' sql2 = 想把資料表 nstock 內 Shop1 6月份的所有資料全部刪除;
wsmaster.BeginTrans
lCommit=true
sql1 = "INSERT INTO stock SELECT * FROM nstock WHERE shop='SHOP1' and sdate='200006' order by icode"
set qrytemp1=dbmaster.createquerydef("")
qrytemp1.sql=sql1
qrytemp1.execute
if qrytemp1.recordsaffected<=0 then
lCommit=false
else
sql2 = "DELETE * FROM nstock WHERE shop='SHOP1' AND sdate='200006'"
set qrytemp2=dbmaster.createquerydef("")
qrytemp2.sql=sql2
qrytemp2.execute
if qrytemp2.recordsaffected<=0 then
lCommit=false
end if
end if
if lCommit=true then
wsmaster.CommitTrans
else
wsmaster.RollBack
end if
問題是,Single User執行 的時候是沒有問題的,在資料表 stock 內可全部找回所表搬的資料;
但在執行Multi-User 的時候某一些資料遺失了,
謝謝!