M
melissa
Unregistered / Unconfirmed
GUEST, unregistred user!
俺要执行一堆比较复杂的操作,我已经做了
try
database.starttransaction
for
begin
……
调用一个别的屏幕的过程
……
end;
except
database.rollback
end;
database.commit
在执行的时候,for循环里面执行了一般的时候,在调用的其他屏幕的过程里面发生了异常,
再回到我这段程序里的异常,可是rollback没回来啊,已经执行的循环里面的数据都已经
被删掉了,再也回不来了,5555
怎么能rollback不回来呢??
下面是俺的代码的超级省略版本
If (query1.RecordCount >0) and (DbGrid1.SelectedRows<>nil) then
try
query3.Close;
query3.sql.Clear;
query3.sql.text:='select p01sts from pmhhdr where p01srn='''+ query1.fieldbyname('p01srn').asstring+'''';
query3.open;
If (query3.fieldbyname('p01sts').asstring<>'C') and (query3.fieldbyname('p01sts').asstring<>'E') then begin
Messagebox(……);
exit;
end;
except
Messagebox(……);
end
else
exit;
try
Application.CreateForm(Taadcbvfy, aadcbvfy);
except
Messagebox(……);
exit;
end;
try
Application.CreateForm(Taadcbchk, aadcbchk);
except
Messagebox(……);
exit;
end;
//开始校验检查
try
if global.Database1.InTransaction then global.Database1.Commit;
global.database1.StartTransaction;
ctno:=111111;
{选出该销售报告的所有票证}
with Query4 do begin
close;
unprepare;
with SQL do begin
Clear;
Add('select * from pwdtkt where p10srn=10srn order by p10tno');
end;
parambyname('p10srn').asstring := query1p01srn.Value;
prepare;
open;
first;
for i:=0 to recordcount-1 do begin
prf:=query4.Fieldbyname('p10prf').asstring;
sty:=query4.Fieldbyname('p10sty').asstring;
ftk:=query4.Fieldbyname('p10ftk').asinteger;
ttk:=query4.Fieldbyname('p10ttk').asinteger;
frm:=query4.Fieldbyname('p10frm').asstring;
vod:=query4.Fieldbyname('p10vod').asstring;
adc:=query4.Fieldbyname('p10adc').asstring;
pta:=query4.Fieldbyname('p10ptk').asinteger;
srn:=query4.Fieldbyname('p10srn').asstring;
agt:=query4.Fieldbyname('p10agt').asstring;
sno:=query4.Fieldbyname('p10sno').asinteger;
tno:=query4.Fieldbyname('p10tno').asinteger;
rsn:=query4.Fieldbyname('p10rsn').asinteger;
cpn:=query4.Fieldbyname('p10cpn').asstring;
rno:=query4.fieldbyname('p10rno').asstring;
rfr:=query4.fieldbyname('p10rfr').asstring;
if(adc='') then begin
flt:='';
act:='';
If (sty<>'R') and (sty<>'O') then begin
aadcbvfy.rmrang(srn,agt,global.USPrefix+frm,ftk,ttk,flt,act,msg,flg4);
if flg4<>'Y' then begin
messagebox(application.handle,pchar(msg),pchar(vsmsg1),0);
raise Exception.Create (pchar(t2));
end;
end;
end;
next;
end;
end;
If global.Database1.InTransaction then global.DataBase1.Commit;
except
global.Database1.Rollback;
aadcbvfy.close;
aadcbchk.close;
Messagebox(……);
exit;
end;
try
database.starttransaction
for
begin
……
调用一个别的屏幕的过程
……
end;
except
database.rollback
end;
database.commit
在执行的时候,for循环里面执行了一般的时候,在调用的其他屏幕的过程里面发生了异常,
再回到我这段程序里的异常,可是rollback没回来啊,已经执行的循环里面的数据都已经
被删掉了,再也回不来了,5555
怎么能rollback不回来呢??
下面是俺的代码的超级省略版本
If (query1.RecordCount >0) and (DbGrid1.SelectedRows<>nil) then
try
query3.Close;
query3.sql.Clear;
query3.sql.text:='select p01sts from pmhhdr where p01srn='''+ query1.fieldbyname('p01srn').asstring+'''';
query3.open;
If (query3.fieldbyname('p01sts').asstring<>'C') and (query3.fieldbyname('p01sts').asstring<>'E') then begin
Messagebox(……);
exit;
end;
except
Messagebox(……);
end
else
exit;
try
Application.CreateForm(Taadcbvfy, aadcbvfy);
except
Messagebox(……);
exit;
end;
try
Application.CreateForm(Taadcbchk, aadcbchk);
except
Messagebox(……);
exit;
end;
//开始校验检查
try
if global.Database1.InTransaction then global.Database1.Commit;
global.database1.StartTransaction;
ctno:=111111;
{选出该销售报告的所有票证}
with Query4 do begin
close;
unprepare;
with SQL do begin
Clear;
Add('select * from pwdtkt where p10srn=10srn order by p10tno');
end;
parambyname('p10srn').asstring := query1p01srn.Value;
prepare;
open;
first;
for i:=0 to recordcount-1 do begin
prf:=query4.Fieldbyname('p10prf').asstring;
sty:=query4.Fieldbyname('p10sty').asstring;
ftk:=query4.Fieldbyname('p10ftk').asinteger;
ttk:=query4.Fieldbyname('p10ttk').asinteger;
frm:=query4.Fieldbyname('p10frm').asstring;
vod:=query4.Fieldbyname('p10vod').asstring;
adc:=query4.Fieldbyname('p10adc').asstring;
pta:=query4.Fieldbyname('p10ptk').asinteger;
srn:=query4.Fieldbyname('p10srn').asstring;
agt:=query4.Fieldbyname('p10agt').asstring;
sno:=query4.Fieldbyname('p10sno').asinteger;
tno:=query4.Fieldbyname('p10tno').asinteger;
rsn:=query4.Fieldbyname('p10rsn').asinteger;
cpn:=query4.Fieldbyname('p10cpn').asstring;
rno:=query4.fieldbyname('p10rno').asstring;
rfr:=query4.fieldbyname('p10rfr').asstring;
if(adc='') then begin
flt:='';
act:='';
If (sty<>'R') and (sty<>'O') then begin
aadcbvfy.rmrang(srn,agt,global.USPrefix+frm,ftk,ttk,flt,act,msg,flg4);
if flg4<>'Y' then begin
messagebox(application.handle,pchar(msg),pchar(vsmsg1),0);
raise Exception.Create (pchar(t2));
end;
end;
end;
next;
end;
end;
If global.Database1.InTransaction then global.DataBase1.Commit;
except
global.Database1.Rollback;
aadcbvfy.close;
aadcbchk.close;
Messagebox(……);
exit;
end;