Subject RE: [firebird-support] Constraint Problem
Author Alan McDonald
> I have a table called "Readers" in a Firebird 2.1 database (FlameRobin
> reports the server version as "WI-V2.1.0.17798 Firebird 2.1"). In the
> latest version of the front-end software driving this database I update
> the table using the following SQL:
>
> ALTER TABLE "Readers" ADD "AlwaysMonitor" SMALLINT NOT NULL;

I suppose you are aware that the "Readers" table is completely different to
a READERS table. Do you have both in the DB by any chance?

>
> Since the field (like others in the table) must not be NULL, the
> front-end software then updates all existing records to have a value of
> 0, and this update is successful (no errors are reported, and
> FlameRobin
> shows the field as being set to 0, not NULL).
>
> However, if I then try to update any other field, I get an error
> reported. DAO reports it as error 3197, but FlameRobin reports:

And you have completely disconnected all client software and admin tools and
re-connected after making this NOT NULL change? It's possible that your
client still thinks it's working with old DD.
You need to look closely at the DAO components as well. It would seem to me
that even though you think you are not updating "AlwaysMonitor", that yo may
be assigning NULL.
Either use an SQL monitor, or test these theories by just updating the field
only in ISQL.
e.g. UPDATE TABLE SET otherfield=VALUE WHERE ID=VALUE;

Alan

>
> The insert failed because a column definition includes validation
> constraints.
> Engine Code: 335544347
> Engine Message:
> validation error for column AlwaysMonitor, value "***null***".

as it should if you are not assigning the value. If you wish to leave the
field out of an INSERT statement, then you need to assign a default value
for the NOT NULL field.