Subject Re: [IBO] Re: Default values not defaulting (newbie)
Author Helen Borrie (TeamIBO)
At 07:55 PM 10-04-02 +0000, bhata wrote:
>With BCB 'ColumnAttributes' is a StringList and the contents
>is empty. I'm guessing you're describing Delphi IDE.

He is describing the Fields Editor for the native IBO datasets. I guess
you are using IBOQuery and an old release of IBO, right? If so, you can
access the ColumnAttributes property through the InternalDataset. Pick up
the TI sheet "Working with Datasets" to see what you need to do to set
these in code.

However, the property you want is DefaultValues, since in this case I don't
think you want to override the NOT NULL attribute of this column.

Something you need to understand about database-defined default
values: they are applied only if both of the following are true:
1) a new record is being inserted (default doesn't work with updates)
2) the column to be defaulted is not present in the insert statement.

If you are using the standard Insert method of the dataset, then the insert
statement WILL include the column. Even if the application passes NULL
(which it will, if the user or the application does not pass a value) the
default will not kick in because the database engine *receives* NULL for
the column. Therefore, if you want a default value, then assign your
default value to the column in DefaultValues, viz.
MyColumn=someconstantvalue

Now, to deal with the other problem, which is the REQUIRED attribute on
your primary key. You don't say whether you are using a generator for this
but, if so, simply set the GeneratorLinks property: RecNum=MyGenerator

If you are not using a generator, you are probably on dangerous ground...


regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com