Subject Re: [IBO] NOT NULL/COMPUTED on query
Author Helen Borrie
At 11:32 AM 25-10-02 +0200, you wrote:
>Hi NG!
>There is a table with a field SAMPLEDATE DATE NOT NULL and a trigger
>I set up a query and a grid, I want empty fields to be sent as null, as
>I expect them to be converted by the trigger.
>So I check: EMPTY AS NULL and COMPUTED in the fields.
>IBO reads the NOT NULL constraint of the fields from the table and
>obviously won't send NULL but 0. As a result I get a date from the
>nineteenth century.
>Is it a bug or a feature?

It is neither. Dates in IB are stored in a numerical format on a time-line
where "date 0" is 17 November 1878 (or thereabouts). The answer is - don't
store a date of zero. If you want your trigger to kick in, then set the
REQUIRED property of this field in the dataset's ColumnAttributes to false
and perform the Clear method on it...even better is to exclude it from your
SQL statement altogether.

Also, a database column is NOT a COMPUTED column. Use this attribute for
columns that are calculated by the SQL of your query.
Some examples:

select fielda as MyField1
sum(aField) as Total
FirstName || ' ' || LastName as FullName

and any subquery output fields are also COMPUTED.