Subject | Re: Non null column, before insert trigger not filling column, Delphi |
---|---|
Author | Mike |
Post date | 2010-06-15T11:57:30Z |
Hello Martijn,
You're right, it's a Delphi message. But the FieldDefs are implicitly created with Required = True from the non-null column definition of the database. This means that I will have to create in my Delphi programs an explicit FieldDef for each usage of the non-null column (in all datasets, etc.) and change the Required setting to False.
I think it will be easier to modify the DDL of the database generation so that the relevant non-null fields which have a Before Insert trigger become generated without the non-null constraint.
At which point, I lose the integrity protection of the database for null values....
It's a hard life...
Regards,
Mike Watson
Datos Informatica.
You're right, it's a Delphi message. But the FieldDefs are implicitly created with Required = True from the non-null column definition of the database. This means that I will have to create in my Delphi programs an explicit FieldDef for each usage of the non-null column (in all datasets, etc.) and change the Required setting to False.
I think it will be easier to modify the DDL of the database generation so that the relevant non-null fields which have a Before Insert trigger become generated without the non-null constraint.
At which point, I lose the integrity protection of the database for null values....
It's a hard life...
Regards,
Mike Watson
Datos Informatica.
--- In firebird-support@yahoogroups.com, "Martijn Tonies" <m.tonies@...> wrote:
>
> 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
>