Jump to content
Henry Olive

Sort Descending on a Calc.Field

Recommended Posts

you can try using "FDLocalSQL" as your hub:

 

example:

  • MyDS_FDMemTableX =  my real data (or any other dataset)
    • in this dataset create a "new field" as "InternalCalc" ... of course, needs to be a field with size and type as your necessity!!!
    • add the event "OnCalcFields" with your expression for create the logic necessary
  • now, you'll need 1 FDConnection, 1 FDLocalSQL and 1 FDQuery
    • 1 FDConnection using SQLite, with ":memory" database...   open it!
    • 1 FDLocalSQL to accomodate your dataset desired... 
      • in this case, this dataset will be "MyDS_FDMemTableX"
    • 1 FDQuery will be used to create your SQL select... pointing to your "MyDS_FDMemTableX"
  • now, open your FDConnection, FDLocalSQL, and your FDQuery to see the result

for more details see the HELP: Delphi Help -> Example and Samples -> FireDAC.TFDLocalSQL InMemDB Sample

 

procedure TForm1.FDMemTable1CalcFields(DataSet: TDataSet);
begin
  FDMemTable1FullNameInternalCalc.AsString := FDMemTable1LastName.AsString+' '+FDMemTable1FirstName.AsString;
end;
 

MyDS_FDMemTableX:

  •     FDMemTable1: TFDMemTable;
  •     FDMemTable1FirstName: TStringField;
  •     FDMemTable1LastName: TStringField;
  •     FDMemTable1FullName: TStringField;
     

FDQuery =    select * from FDMemTable1  order by FullNameInternalCalc

 

 

image.thumb.png.c21a132b96a431bf6731a8e429500b62.png

Edited by programmerdelphi2k

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×