zoukankan      html  css  js  c++  java
  • DATASNAP中间件调用带OUTPUT参数的存储过程

    服务端:

    function TServerMethods1.spExecOut(funcId, sqlId,

    inParams: OleVariant): OleVariant;
    var
    d: TfrmDB;
    procName: string;
    params: TFDParams;
    i, h: Integer;
    begin
    Result := null;
    d := DBPool.Lock;
    if not Assigned(d) then
    Exit;
    try
    try
    procName := frmBuffer.GetSqlSelect(funcId, sqlId);
    if procName = '' then
    Exit;
    d.proc.Close;
    d.proc.StoredProcName := procName;
    d.proc.Prepare;
    params := TFDParams.Create;
    try
    UnpackFDParams(inParams, params);
    for i:=0 to params.Count -1 do
    for h:=0 to d.proc.ParamCount-1 do
    if d.proc.Params[h].Name = params[i].Name then
    begin
    if d.proc.Params[h].ParamType=ptInput then
    begin
    d.proc.Params[h].Value := params[i].Value;
    Break;
    end;
    end;
    finally
    params.Free;
    end;
    d.proc.ExecProc;
    Result := PackageFDParams(d.proc.Params);
    except
    on e: Exception do
    begin
    Result := null;
    Log.WriteLog('TServerMethods1.spExecOut ' + e.Message);
    Exit;
    end;
    end;
    finally
    DBPool.Unlock(d);
    end;
    end;

    客户端调用:

    procedure TfrmMain.Button2Click(Sender: TObject);
    var
    r:OleVariant;
    p:TParams;
    begin
    p:=TParams.Create(nil);
    p.Clear;
    p.CreateParam(ftInteger,'@a',ptInput).Value :=1;
    p.CreateParam(ftInteger,'@b',ptInput).Value :=2;
    p.CreateParam(ftInteger,'@c',ptOutput);
    r := spExecOut('9999','3',PackageParams(p));
    UnpackParams(r,p);
    p.ParamByName('@c').Value;
    p.Free;
    end;

    end.

  • 相关阅读:
    redis运维手册
    grafana展示ES中的nginx日志-地图展示
    nginx针对yum安装nginx重编译
    K8S-yaml里初始化容器
    K8S-资源配置清单补充1
    K8S-资源配置清单详解
    Docker cp 提示“no space left on device”
    磁盘
    ansible 对文件内容的操作
    ansible 初始化系统分区格式化
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/4928187.html
Copyright © 2011-2022 走看看