Subject Re: [IBO] Posting nulls into NOT NULL fields.
Author Helen Borrie
At 04:35 PM 14-10-01 +0200, you wrote:
>Hello,
>
>With the versions > 4.2 Ee I have the following problem:
>
>With TIBOQuery I can post null values into fields defined in InterBase as
>NOT NULL.

I believe that you will discover that no nulls have been posted. In TDataset, all "empty" fields are made to be zero-equivalent - zero in numerics and dates, empty string (#0) in character fields.

To post a null, you have to do one of two things:

a) exclude the field in question from your update SQL statement. IOW, if you are using the standard Insert() method on a dataset that selects your non-nullable field, Delphi will post a zero-equivalent
b) explicitly make the field's value null by calling Clear, e.g.
FieldByName('MyField').Clear;


>With TIB_Query I solved this problem with ColumnAttributes
>MyField=BLANKISNULL.

The BLANKISNULL attribute forces (b) above on the field it applies to.


>How it is possible that InterBase not null fields accept null values ?

It isn't possible. If you wish to post nulls, you must do a) or b) above and also set CheckRequired false on that field.

regards,
Helen



>Thanks for help
>
>Peter Czarnecki
>Eustachio SA
>
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________