Reinier Olislagers wrote / napĂsal(a):
With this code:
procedure SortBufDataSet(DataSet: TBufDataSet; const FieldName: string);
var
Index_Name: string;
begin
Index_Name := FieldName + '__IdxA';
if (DataSet.IndexDefs.Find(Index_Name)<>Nil) then
...
the last line throws an exception if the index does not exist;
corresponding db.pas code:
function TIndexDefs.Find(const IndexName: string): TIndexDef;
begin
Result := (inherited Find(IndexName)) as TIndexDef;
if (Result=Nil) Then
DatabaseErrorFmt(SIndexNotFound, [IndexName], FDataSet);
end;
However, the documentation states:
Find...returns Nil if no matching index definition was found.
Not a Delphi guy - should the implementation or the documentation be fixed?
Delphi documentation says, that exception is raised
http://docwiki.embarcadero.com/Libraries/XE2/en/Data.DB.TIndexDefs.Find
May be, that IndexOf can be used to find index without raising exception.
-Laco.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal