IBX5.03: IBTable.Locate('FieldName','Já',[loCaseInsensitive]) - Charset ISO8859-1
IBX5.03 D5.
The statment below does not work properly with charater set ISO8859-1.
IBTable.Locate('FieldName','J',[loCaseInsensitive])
Looking into the code I've found
function TIBTable.InternalLocate(const KeyFields: string;
const KeyValues: Variant; Options: TLocateOptions): Boolean;
var
IsGood : TIBSQL;
fl: TList;
i, fld_cnt : Integer;
fString, pString, eString : String;
val : Array of Variant;
begin
IsGood := TIBSQL.Create(Database);
IsGood.Transaction := Transaction;
IsGood.SQL.Text := 'select ' {do not localize}
+ 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize}
+ QuoteIdentifier(DataBase.SQLDialect, FTableName);
fl := TList.Create;
try
GetFieldList(fl, KeyFields);
fld_cnt := fl.Count;
SetLength(val, fld_cnt);
for i := 0 to fld_cnt - 1 do
if VarIsArray(KeyValues) then
val[i] := KeyValues[i]
else
val[i] := KeyValues;
if loCaseInsensitive in Options then
begin
fString := 'UPPER(%:0s)'; {do not localize}
===>> //pString := 'UPPER(:%:0s) '; {do not localize} ===> UPPER
function with parameter does not work properly: UPPER('J') returns 'J'
pString := '(:%:0s) '; {do not localize} // this works fine
end
else
begin
fString := '%:0s'; {do not localize}
pString := ':%:0s '; {do not localize}
end;
if loPartialKey in Options then
eString := ' starting with ' {do not localize}
else
eString := ' = '; {do not localize}
for i := 0 to fld_cnt - 1 do
begin
if i > 0 then
begin
if VarIsNull(val[i]) then
isGood.SQL.Add(Format(' and %s is null ', {do not localize}
[QuoteIdentifier(DataBase.SQLDialect,
TField(fl[i]).FieldName)]))
else
isGood.SQL.Add(Format(' and ' + fString + eString + pString, {do
not localize}
[ QuoteIdentifier(DataBase.SQLDialect,
TField(fl[i]).FieldName)]));
end
else
begin
if VarIsNull(val[i]) then
isGood.SQL.Add(Format(' Where %s is null ', {do not localize}
[QuoteIdentifier(DataBase.SQLDialect,
TField(fl[i]).FieldName)]))
else
isGood.SQL.Add(Format(' Where ' + fString + eString + pString,
{do not localize }
[ QuoteIdentifier(DataBase.SQLDialect,
TField(fl[i]).FieldName)]));
end;
end;
for i := 0 to fld_cnt - 1 do
if not VarIsNull(val[i]) then
// modifications below are needed because we removed the UPPER
function above
==>> //isGood.Params.ByName(TField(fl[i]).FieldName).Value :=
val[i];
if loCaseInsensitive in Options then
isGood.Params.ByName(TField(fl[i]).FieldName).Value :=
AnsiUpperCase(val[i]) // must be AnsiUpperCase
else
isGood.Params.ByName(TField(fl[i]).FieldName).Value := val[i];
IsGood.ExecQuery;
if IsGood.Eof then
Result := false
else
Result := inherited Locate(KeyFields, KeyValues, Options);
finally
IsGood.Free;
fl.Free;
val := nil;
end;
end;
best regards
Fabiano Rezende