TConnection的ExecuteSQL方法返回值始终为-1,为什么?
FConnection.:=TConnection.Creat(nil);
FConnection.ConnectionString:='DATABASEURL=Biz:\GYLGLXT\YWSJK.Database';
FConnection.Transaction:=TTransaction.Create(FConnection);
lHandle:=FConnection.Transaction.Start(False);
try
if lInfo.StoreID='' then
begin
Raise Exception.Create('出库仓库没有指定,不能出库!');
exit;
end;
AMount:=lInfo.Amount;
lSQL:='select GUID from OutDetail where GUID in ('+GetOutSQL+')';
if FConnection.ExecuteSQL(lSQL)>0 then
begin
Raise Exception.Create('物资已经出库,请不要重复操作!');
exit;
end;
//冲减库存量
lSQL:='update wlkcb set kcl=kcl-(%f) where Barcode=''%s'' and cfck=''%s'' and kcl>=%f';
lSQL:=SysUtils.Format(lSQL,[AMount,lInfo.BarCode,lInfo.StoreID,AMount]);
Affected:=FConnection.ExecuteSQL(lSQL);
if Affected<=0 then Raise Exception.Create('库存不足,不能出库!');
try
FConnection.Transaction.Commit(lHandle);
except
FConnection.Transaction.rollback(lHandle);
end;
finally
FConnection.Free;
end; |