Subject Re: [IBO] Null and numeric fields
Author Helen Borrie
At 12:09 PM 31/05/2006, you wrote:
>(Using FB 1.03, IBO 4.5B)
>
>In one of my tables I have two numeric(15,2) columns
>
>CREATE DOMAIN DM_MONEY AS
>NUMERIC(15,2)
>DEFAULT 0.00
>
>CREATE TABLE JEVENTRIES (
> ID INTEGER NOT NULL,
> JEVID INTEGER NOT NULL,
> GL VARCHAR(10),
> SL VARCHAR(10),
> ACTIVITYCODE VARCHAR(3),
> EXPENSETYPECODE VARCHAR(3),
> DRAMOUNT DM_MONEY,
> CRAMOUNT DM_MONEY
>)
>
>Clientside I set the following values for DefaultValues
>dramount=0.00
>cramount=0.00
>
>My problem is I still get null values with dramount and cramount
>sometimes, but not always. This problem occurs only when using the
>client program (using IBO). At one point I even set GetServerDefaults
>to true to no avail.
>
>Are there issues regading this behaviour? What should I do to ensure
>non-null values in the numeric fields?

Did you realise that the default constraint applies only in the
following circumstances:

1) when inserting; AND
2) when the said column is NOT included in the INSERT statement

To ensure a null is never stored, you should constrain the column (or
the domain) as NOT NULL.

Alternatively, you could add a CHECK constraint and a trigger:

alter table blah
add constraint MyFieldNotNull
check (Myfield is not null)

Then, in IBO, you can flag blah.MyField as Required in
ColumnAttributes at dataset or connection level.

However, the advantage of actually defining the column or domain as
NOT NULL is that IBO knows about it, so IBO will throw an exception
in BeforePost if there is no value there. (Constraining a column or
domain as NOT NULL) is different from applying a check constraint to
force not null)

Helen