2

Given a PostgreSQL table with an index like:

DROP INDEX IF EXISTS RefNo1;
CREATE INDEX RefNo1 ON MyTable (RefNo1 NULLS FIRST, Date DESC NULLS FIRST, GLPostDate DESC NULLS FIRST);

If I drop a TFDTable down, assign it to this table, and set the IndexName property to RefNo1 the resulting dataset has the null values at the bottom. Going through the trace log indicates that FireDAC selected without the NullsFirst option. So I go into FormatOptions.SortOptions and set NullsFirst to True. Still no change. Strs2EmptyNull provides no relief.

This is possible if I use TFDQuery in combination with managing the Indexes collection.

Am I missing something to get the NullsFirst option working in TFDTable? There's no Indexes collection under TFDTable. I can set IndexFieldNames like so:

refno1;date:D;glpostdate:D

But I see no option to specify NULLS FIRST.

2
  • There's no Indexes collection under TFDTable. TFDTable does have Indexes property, but it isn't published.
    – BrakNicku
    Sep 29 at 9:16
  • Can you do anything with the Indexes collection at runtime? I tried something like SomeIndex := TblJournal.Indexes.Add; SomeIndex.Fields := 'refno1;date;glpostdate'; SomeIndex.DescFields := 'date;glpostdate'; SomeIndex.Options := [soNullFirst]; SomeIndex.Name := 'newrefno1'; SomeIndex.Active := True; But setting the IndexName to 'newrefno1' still puts nulls last.
    – FLDelphi
    Sep 29 at 15:32

1 Answer 1

2

Instead of TFDTable use TFDQuery. Create FDIndex (duble click on Indexes) and set FDIndex.Options.soNullFirst

1
  • Is that all there is? We are moving databases from Advantage to Postgre and have used TAdsTables somewhat extensively. So right now we are converting TAdsTables to TFDTables (where this all works fine btw).
    – FLDelphi
    Sep 29 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.