SDAC Default or NULL

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 3
Joined: Sun 27 Apr 2008 21:50
Location: Norway

SDAC Default or NULL

Post by PerW » Sun 27 Apr 2008 22:13

I use Cbuilder 2006 and latest SDAC and MSSQL 2005
I have some money field with default value (0). A do some calculation so I can't have values of NULL.
But if a delete all values and send 'NULL' from the program MSSQL acept this and update the table with NULL value even default is (0).
I don't now if this is a MSSQL error or SDAC error.
For me it makes no sens to be able to update a column with NULL when deafault value is (0).

Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 29 Apr 2008 09:08

Try to use the default keyword in your queries instead of NULL:

INSERT INTO tb_default_test (c_default) VALUES(default)

If you perform the changes editing a dataset but not executing queries directly, you should write a code like this in the BeforeUpdateExecute event handler of your dataset:

Code: Select all

  Param: TParam;
  Param := Params.FindParam('c_default');
  if (Param  nil) and Param.IsNull then
    Param.Bound := False;

Post Reply