Subject | RE: [firebird-support] Defaults and Delphi 6.0 |
---|---|
Author | Alan McDonald |
Post date | 2005-09-01T23:55:42Z |
> I created a new table and set default values for certain fields.first mistake - forget using TIBTable - get used to using TIBQuery until you
> When I edit the table using IBOCONSOLE, as soon as I add a new
> record, the fields for which default values are defined, are
> populated with the default values. So far so good.
>
> Now I go to Delphi and create a small test app. I am using the IB
> componets that came with D6 (at least I think they came with D6). I
> use a IBDatabase, an IBTable and a regular datasource component to
> access the data. I then drop in a DBGrid and link everything
> together. When I insert a new rec in the grid, the default values
> don't show up. I even tried other data aware components and I still
> don't get thos default values to show up. What am I doing wrong?
>
> Thank you
know what you're doing
Second, depending on the SQL which is given to the server for the insert,
you may be sending NULL values. If the field is defined as NULLable, then
the default values will not be created.
IF you want the default values to be created, then you do not include these
fields in the SQL insert statement.
Experiment with this in IBOConsole. Do INSERT (FIELDLIST...) VALUES
(NULLVALUE...)
and compare this with INSERT(pkfield) VALUES(100) - leaving the other fields
out and see your defaults appear.
Alan