比如
函数A执行两条数据操作,并作为一个事务;
procedure A;
begin
try
AdoConnection1.BeginTrans;
AdoQuery1.sql.text:='update ....';
AdoQuery1.ExecSQL;
AdoQuery1.sql.text:='insert ....';
AdoQuery1.ExecSQL;
AdoConnection1.CommitTrans;
except
AdoConnection1.RollbackTrans;
end;
end;
函数B执行两条数据操作,并作为一个事务;
procedure B;
begin
try
AdoConnection1.BeginTrans;
AdoQuery1.sql.text:='update ....';
AdoQuery1.ExecSQL;
AdoQuery1.sql.text:='insert ....';
AdoQuery1.ExecSQL;
AdoConnection1.CommitTrans;
except
AdoConnection1.RollbackTrans;
end;
end;
函数C同时执行A、B,并也作为一个事务;
procedure C;
begin
try
AdoConnection1.BeginTrans;
A;
B;
AdoConnection1.CommitTrans;
except
AdoConnection1.RollbackTrans;
end;
end;
但是,运行结果,函数C 运行不通过。
如果解决事务不能我上面这种函数嵌套的问题
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货