Board index » delphi » Problem with Locate in IBX45
Alexandr Golubev
![]() Delphi Developer |
Thu, 14 Aug 2003 17:45:31 GMT
Problem with Locate in IBX45
I've found a problem using Locate in a TIBDataset with the new version IBX45
Next variants of using function Locate have problems: 1. IBDataSet.Locate('COD', null, [...]); for Lookup fields when data KEY fields is null 2. IBDataSet.Locate('COD', VarArrayOf('111'), [...]); for one field and search data as VarArray 3. IBDataSet.Locate('COD;NAME', .....); for count field names more than 1 ---------------------------- For correct work of function TIBCustomDataSet. InternalLocate I was compelled to change an initial code. At modification I used the appropriate text of the version IBX442. Jeff, please, look critically at the following code and tell your opinion. Your change ( result := result and (AnsiPos(val[i], fld_str) = 1) ) I use in my text. ----------------------------- function TIBCustomDataSet.InternalLocate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; var fl: TList; CurBookmark: string; fld : Variant; val : Array of Variant; i, fld_cnt: Integer; fld_str : String; begin fl := TList.Create; result := False; // before GetFieldList(fl, KeyFields) if bad field name try GetFieldList(fl, KeyFields); fld_cnt := fl.Count; CurBookmark := Bookmark; SetLength(val, fld_cnt); if not Eof then for i := 0 to fld_cnt - 1 do begin if (fld_cnt > 1) or VarIsArray(KeyValues) then // Alex (for case #2 and #3) val[i] := KeyValues[i] // Alex else // Alex val[i] := KeyValues; // Alex if not VarIsNull(val[i]) then // Alex add while ((not result) and (not EOF) and (fld_cnt > 0)) do // alex add ----------- |