zoukankan      html  css  js  c++  java
  • 提交主从表的多个已经修改的数据

    网上有一些讲以RAD方式设置主从表的演示,但是在实际当中不实用。

    function TsvrDM.ApplyUpdates(const ModuleId: WideString;sqlId:ShortInt; Delta0,
      Delta1, Delta2, Delta3: OleVariant): Shortint;
    const
      sql='Select * from %s where 1<>1'; 
    var
      aData: array of OleVariant;
      i:integer;
      conn:TADOConnection;
      qry:TADOQuery;
      dsp:TDataSetProvider;
      errCount:integer;
    begin
      try
        Result :=0;
        tableList.Clear;
        tableList.DelimitedText:=GetSqlCommand(ModuleId,sqlid); // table name list
        if tableList.Count = 0 then
        begin
          Result :=0;
          exit;
        end;
        if Delta0 <>Null then
        begin
          SetLength(aData, 1);
          aData[0]:=DeCompressData(Delta0);
        end;
        if Delta1<>Null then
        begin
          SetLength(aData,1);
          aData[1]:=DeCompressData(Delta1);
        end;
        if Delta2<>Null then
        begin
          SetLength(aData,2);
          aData[2]:=DeCompressData(Delta2);
        end;
        if Delta3<>Null then
        begin
          SetLength(aData,3);
          aData[3]:=DeCompressData(Delta3);
        end;
        conn:=ConnPool.Lock;
        qry:=QryPool.Lock;
        dsp:=DSPPooler.Lock;
        conn.BeginTrans;
        try
          try
            qry.Connection := conn;
            dsp.DataSet := qry;
            for i:=Low(adata) to High(adata) do
            begin
              qry.Close;
              qry.SQL.Clear;
              qry.SQL.Text:=Format(sql,[tableList.Strings[i]]);  // table name
              qry.Open;
              if (qry.Active) and (aData[i]<>Null) then
                dsp.ApplyUpdates(aData[i],0,ErrCount);
              qry.Close;
            end;
          finally
            ConnPool.Unlock(conn);
            QryPool.UnLock(qry);
            DSPPooler.UnLock(dsp);
          end;
          conn.CommitTrans;
        except
          Result:=0;
          conn.RollbackTrans;
          Exit;
        end;
        Result :=1;
      except
        Result :=0;
        Exit;
      end;
    end;

  • 相关阅读:
    微擎 关注发送推荐消息
    修改 processor.php 文件,监听用户对该应用的消息
    微擎返回图文信息
    微擎客服消息发送的函数
    mui 底部导航栏的实现
    两张表的关联查询
    微擎 截取字符串
    webStorm中NodeJs 没有智能提示
    OpenCV 实现自己的线性滤波器
    OpenCV 基本的阈值操作
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2368617.html
Copyright © 2011-2022 走看看