2

I'm moving code from Delphi 2007 + AnyDac to Delphi XE4 + FireDac. In AnyDac case all empty strings were stored like NULL, and in FireDac all empty strings are stored like empty string ''.

I need to go back to NULL's. What is the best way of doing that? I store to DB using params:

ADQuery.Params.ParamByName('Code').Value :=Code;
Jan Doggen
  • 8,154
  • 13
  • 56
  • 117
vico
  • 13,725
  • 30
  • 108
  • 237
  • You say "stored", but this is controlled by database. What's your database? – Marcus Adams Dec 16 '13 at 15:59
  • @Marcus, primarily by a dataset control itself (see the post below)... After then it's upon database how it stores. – TLama Dec 16 '13 at 16:12
  • @TLama, if you assume the only point of access to the database is your dataset control. There's room for a more complete answer if OP answered my question. – Marcus Adams Dec 16 '13 at 20:50

1 Answers1

4

Include (set it to True in the Object Inspector) the StrsEmpty2Null option to the FormatOptions of your dataset object. The reference says (emphasized by me):

Controls the conversion of zero-length string values to NULL value. Use the StrsEmpty2Null property to control whether FireDAC should convert string values with zero length to NULL value (True) or not (False). The default value is False.

TLama
  • 71,521
  • 15
  • 192
  • 348