• 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.

  • 相关阅读:
    Python保留最后N个元素
    STL算法
    STL迭代器
    STL容器
    C++总结1
    牛客剑指Offer2
    Vue第一天
    UML
    Java继承和组合代码
    Java15后的sealed阻止继承滥用
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/4928187.html
Copyright © 2020-2023  润新知