Subject Re: [firebird-support] Non null column, before insert trigger not filling column, Delphi
Author Martijn Tonies
Hello Mike,

> I have an 'ID' INTEGER column without a non-null constraint. The table has
> a BEFORE INSERT trigger that executes the generator that fills the column.
> When I post a new record the trigger fires and creates the ID column value
> correctly.
>
> However, if the 'ID' column has a non-null constraint when I post I get an
> error: 'Column ID must have a value'.
>
> I would have expected the trigger to have filled the column but apparently
> the constraint checking takes precedence.

The trigger does fill it, this message is coming from Delphi, not Firebird.

> Is this foreseen, that is, is this normal or is this a bug?

Normal if your TField definition has the Required property set to True.

> Obviously, I could simply take off the non-null constraint but I am
> converting to Firebird with rougly 50 tables, each with a ID column of
> this type, so I would have to edit 50 table definitions.
>
> Can anyone clarify theis situation?

See above.

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com