加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – TClientDataSet过滤器是否有限制,还是一个bug?

发布时间:2020-12-15 09:23:21 所属栏目:大数据 来源:网络整理
导读:我正在使用TClientDataSet作为内存表,并且必须应用具有许多条件的过滤器. 例如,对于400 OR条件,当我尝试启用过滤器时,我收到访问冲突. Access violation at address 4DAEDC76 in module ‘midas.dll’. Read of address 00000034. 此处发生异常: procedure
我正在使用TClientDataSet作为内存表,并且必须应用具有许多条件的过滤器.

例如,对于400 OR条件,当我尝试启用过滤器时,我收到访问冲突.

Access violation at address 4DAEDC76 in module ‘midas.dll’. Read of address 00000034.

此处发生异常:

procedure TCustomClientDataSet.AddExprFilter(const Expr: Widestring; Options: TFilterOptions); 
begin 
  if FExprFilter <> nil then FDSCursor.DropFilter(FExprFilter); 
  if Expr <> '' then 
  with TExprParser.Create(Self,Expr,Options,[poExtSyntax],'',nil,FieldTypeMap,True) do 
    try 
      CheckProviderEOF; 
      Check(FDSCursor.AddFilter(FilterData,DataSize,FExprFilter)); // ** AV HERE
    finally 
      Free; 
    end; 
end;

它是组件上的错误还是midas.dll的限制?
我在这些midas版本上测试了这种行为:> = 15和< = 23 我正在使用Delphi XE.
示例代码:

procedure TForm41.Button1Click(Sender: TObject);
var
  I: Integer;
  FilterStr: string;
begin
  FilterStr := '(vehicleId = -1)';
  //It is just an example,the original code I can have any integer number.
  for I := 0 to 400 do //If I change the limit value to 40 for example,it works. 
    FilterStr := FilterStr + ' or (vehicleId = ' + IntToStr(I) + ')';

  ClientDataSet1.Filter := FilterStr;
  ClientDataSet1.Filtered := True;
  ClientDataSet1.CreateDataSet; //Error here
end;

我已经尝试过使用IN语句,但是我得到了同样的错误.

我没有在互联网上找到有关这种情况的参考资料.

解决方法

我可以重现这个错误,包括Delphi Seattle中的“读取地址00000034”.
当Filter表达式中有超过280个术语时,就会发生这种情况.它的
显然是midas限制.您需要一种更好的翻译问题域的方法
达到所需的过滤效果.

如果您可以在代码中评估您的条件,那么我要做的就是添加CDS的布尔值fkInternalCalc字段,并将其设置为True的False取决于结果.然后,过滤数据集很简单根据布尔值的值应用过滤器.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读