从数据池中捞取的存储过程控件使用完以后必须unprepare

存储过程控件Unprepare必要性

从数据池中捞取的存储过程控件使用完以后必须unprepare,否则会造成输入参数是仍是旧的BUG。

提示:动态创建的存储过程控件无此BUG。此BUG只限于从数据池中捞取的存储过程控件。

function TServerMethods1.spOpen(const accountNo, spName: WideString; inParams: OleVariant): OleVariant;
var
d: TfrmDB;
params: TParams;
i: Integer;
param: TFDParam;
begin
Result := null;
if (accountNo = '') or (spName = '') then
Exit;
d := GetDBPool(accountNo).Lock;
if not Assigned(d) then
Exit;
try
try
d.procOpen.Close;
d.procOpen.params.Clear;
d.procOpen.StoredProcName := spName;
d.procOpen.Prepare;
params := TParams.Create;
try
UnpackParams(inParams, params);
for i := 0 to params.Count - 1 do
begin
param := d.procOpen.FindParam(params[i].Name);
if not Assigned(param) then
Continue;
param.value := params[i].value;
end;
finally
params.Free;
end;
Result := d.dspProcOpen.Data;
except
on e: Exception do
begin
Result := null;
Log.WriteLog('TServerMethods1.spOpen ' + e.Message);
Exit;
end;
end;
finally
d.procOpen.Close;
d.procOpen.Unprepare;  // 从数据池中捞取的存储过程控件使用完以后必须unprepare
GetDBPool(accountNo).Unlock(d);
end;
end;

转载于:https://www.cnblogs.com/hnxxcxg/p/6687361.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值