Subject Re: [ib-support] Default values not working
Author Martijn Tonies

> I have the SQL
> Alter table mytable add myfield integer default 0 not null;
> This will add the new field, for all existing records populate the
> new field with the value 0, but if a insert a new record - through my
> app or IBConsole - it forces me te enter a value.
> Leaving out the 'not null' allows nulls to be left out.
> ( I also try default '0' - same effect )
> Interbase v6

The DEFAULT clause only works if you leave out the field in the

For example,

INSERT INTO mytable (col1, col2, col3, myfield) VALUES ( etc)

This will not use the DEFAULT value - not even if the value for
myfield is NULL.

Leave the column from the INSERT and you should be fine.

And if you have a grid or other way to enter your data, the TField
implemention will check the "required" attribute and set it to True ->
it validates before sending the statement to IB. Set this to False too.

Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird

Upscene Productions

"This is an object-oriented system.
If we change anything, the users object."