Good afternoon,
While doing some test I found out the following very small bug:
I used the function
// Search a record in a dataset
function TOracleDataSet.SearchRecord(const FieldNames: string; const FieldValues: Variant;
Options: TSearchRecordOptions): Boolean;
with the options [srFromBeginning, srIgnoreCase, srPartialMatch, srWildCards]
However, if I want to find the record with the field value 'ALEGRIA' then
OracleDataset1.SearchRecord(field,'*EGRIA',[srFromBeginning, srIgnoreCase, srPartialMatch, srWildCards]);
does not work, but
OracleDataset1.SearchRecord(field,'**EGRIA',[srFromBeginning, srIgnoreCase, srPartialMatch, srWildCards]);
does work !
Looking in your source code OracleData.pas I found the error. Because of the srPartialMatch the string is stripped even when there is a wildcard in the mask string. In the above example , the code tries to compare 'EGRIA' with 'EGRI' which will result false.
It might be an idea to change the code
if srPartialMatch in Options then
s := Copy(s, 1, Length(StringArray[f]));
if srWildcards in Options then
Match := WildCardCompare(StringArray[f], s)
else
Match := (stringArray[f] = s);
into something like this:
if (srPartialMatch in Options) and not ((srWildCards in Options) and (Pos('*', StringArray[f]) 0)) then
s := Copy(s, 1, Length(StringArray[f]));
if srWildcards in Options then
Match := WildCardCompare(StringArray[f], s)
else
Match := (stringArray[f] = s);
In this case the srPartialMatch will not strip the string in case of an srWildCards and a '*' in the mask string.
[This message has been edited by smouge (edited 20 June 2003).]
[This message has been edited by smouge (edited 20 June 2003).]
While doing some test I found out the following very small bug:
I used the function
// Search a record in a dataset
function TOracleDataSet.SearchRecord(const FieldNames: string; const FieldValues: Variant;
Options: TSearchRecordOptions): Boolean;
with the options [srFromBeginning, srIgnoreCase, srPartialMatch, srWildCards]
However, if I want to find the record with the field value 'ALEGRIA' then
OracleDataset1.SearchRecord(field,'*EGRIA',[srFromBeginning, srIgnoreCase, srPartialMatch, srWildCards]);
does not work, but
OracleDataset1.SearchRecord(field,'**EGRIA',[srFromBeginning, srIgnoreCase, srPartialMatch, srWildCards]);
does work !
Looking in your source code OracleData.pas I found the error. Because of the srPartialMatch the string is stripped even when there is a wildcard in the mask string. In the above example , the code tries to compare 'EGRIA' with 'EGRI' which will result false.
It might be an idea to change the code
if srPartialMatch in Options then
s := Copy(s, 1, Length(StringArray[f]));
if srWildcards in Options then
Match := WildCardCompare(StringArray[f], s)
else
Match := (stringArray[f] = s);
into something like this:
if (srPartialMatch in Options) and not ((srWildCards in Options) and (Pos('*', StringArray[f]) 0)) then
s := Copy(s, 1, Length(StringArray[f]));
if srWildcards in Options then
Match := WildCardCompare(StringArray[f], s)
else
Match := (stringArray[f] = s);
In this case the srPartialMatch will not strip the string in case of an srWildCards and a '*' in the mask string.
[This message has been edited by smouge (edited 20 June 2003).]
[This message has been edited by smouge (edited 20 June 2003).]