Subject | Possible bug in IB_IncSearch and bugfix |
---|---|
Author | Oliver Wurdak |
Post date | 2002-12-02T16:46:07Z |
Hi
I have a problem with the TIB_IncSearch. When I search a key the dataset
pointer moves till EOF.
I look into the source to find the reason.
I find the TIB_BDataset.SysIncSearch function. Without the knowledge about
the exact behaviour of the function, I see that only a few rows (and their
keys) are compared with the searchstring.
here is an example of the keys in my dataset
search for B in Inc_search
Axxxx <- first compare
Axxxx
Axxxx
Axxxx <- second compare
Bxxxx
Bxxxx
NULL <- third compare
NULL
NULL
The compare function is TIB_BDataset.DoCompareStr
in the third compare there is a compare with NULL
the AnsiCompareStr returns -1 and therefore the dataset scolls till EOF
I changed the TIB_BDataset.DoCompareStr function to:
begin
if Assigned( IB_Connection.OnCustomCompareStr ) then
Result := IB_Connection.OnCustomCompareStr( IB_Field, S1, S2 )
else
begin
if S1=#0 then result:=1 //<-----------------------
else Result := AnsiCompareStr(S1,S2);
end
end;
and everything is ok
for a general solution I should know wether the NULL are first or last
(heard that you can choose this in firebird )
lg Oliver
I have a problem with the TIB_IncSearch. When I search a key the dataset
pointer moves till EOF.
I look into the source to find the reason.
I find the TIB_BDataset.SysIncSearch function. Without the knowledge about
the exact behaviour of the function, I see that only a few rows (and their
keys) are compared with the searchstring.
here is an example of the keys in my dataset
search for B in Inc_search
Axxxx <- first compare
Axxxx
Axxxx
Axxxx <- second compare
Bxxxx
Bxxxx
NULL <- third compare
NULL
NULL
The compare function is TIB_BDataset.DoCompareStr
in the third compare there is a compare with NULL
the AnsiCompareStr returns -1 and therefore the dataset scolls till EOF
I changed the TIB_BDataset.DoCompareStr function to:
begin
if Assigned( IB_Connection.OnCustomCompareStr ) then
Result := IB_Connection.OnCustomCompareStr( IB_Field, S1, S2 )
else
begin
if S1=#0 then result:=1 //<-----------------------
else Result := AnsiCompareStr(S1,S2);
end
end;
and everything is ok
for a general solution I should know wether the NULL are first or last
(heard that you can choose this in firebird )
lg Oliver