Delphi ADO更新条件

转https://blog.51cto.com/kinwar/1686710

代码将导致 ADO 在 WHERE 子句中包括的每个字段。如果您想确保所做的当前用户更新才会成功如果为表格中的行中的任何字段中不进行了任何更改,将"更新条件"属性中使用此值。

此属性可用的常数,如下所示:
   adCriteriaKey = 0

      Uses only the primary key

   adCriteriaAllCols = 1

      Uses all columns in the recordset

   adCriteriaUpdCols = 2  (Default)

      Uses only the columns in the recordset that have been modified

   adCriteriaTimeStamp = 3

      Uses the timestamp column (if available) in the recordset
    
注意: 指定 adCriteriaTimeStamp 可能实际使用 adCriteriaAllCols 方法执行更新,如果表中没有一个有效的时间戳字段。另外,时间戳字段不必在该记录集本身。

 

  //纱订单明细
  with adods_YarnJobDetail_PO do
  begin
    Active := False;
    CommandText := 'SELECT  job_item_id=a.Iden,a.Reserved_Qty,a.Quantity,a.Order_Status,a.Yarn_Type,a.Yarn_Count,a.Color_Code ' + #13#10 +
                   'FROM    AX_YarnPPODetail a WITH ( NOLOCK )' + #13#10 +
                           'JOIN AX_YarnPPOHead c WITH ( NOLOCK ) ON a.PPO_No = c.PPO_No' + #13#10 +
                           'LEFT JOIN SystemDb..pbYarnTypeList d WITH ( NOLOCK ) ON a.Yarn_Type = d.Yarn_Type' + #13#10 +
                           'LEFT JOIN systemdb..pbcustomerlist f WITH ( NOLOCK ) ON c.Customer_CD = f.Customer_Code' + #13#10 +
                           'WHERE   a.Yarn_Type = :Yarn_Type' + #13#10 +
                           'AND a.Yarn_Count = :Yarn_Count' + #13#10 +
                           'AND a.Quantity-Reserved_Qty>0' + #13#10 +
                           'AND d.Flag <> ''N''' + #13#10 +
                           'AND LOWER(a.Order_Status)=''confirmed''' + #13#10 +
                           'AND c.Order_Type=N''PO''';
     Parameters.ParamByName('Yarn_Type').Value := vYarn_Type;
     Parameters.ParamByName('Yarn_Count').Value := vYarn_Count; 
     Open;
     Properties['update criteria'].value := 1;
   end;
   Result := true;

 

posted @ 2020-04-22 11:28  Tag  阅读(164)  评论(0编辑  收藏  举报