-1

I am using a grid to enter data and find that my fields that are marked as NOT NULL but have a DEFAULT CONSTRAINT eg. int = 0 are not being automatically updated with the default value.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
GlynB
  • 1

1 Answers1

0

From the Delphi XE8 documentation:

FireDAC does not automatically fetch column default expressions from the database dictionary.

The standard Delphi way to define default values is to handle the TDataSet.OnNewRecord event and explicitly set the defaults at runtime.

But FireDAC does offer another solution:

FireDAC allows you to assign an expression to the TField.DefaultExpression property. This expression will be evaluated one time as part of the Insert / Append method call and assigned as an initial value to the corresponding field.

This can be done at design time using the fields editor.

I prefer the former solution, but that is because often my datasets are defined at runtime via dynamic SQL... so the latter is not an option.

Frazz
  • 2,995
  • 2
  • 19
  • 33