Subject Re: [IBO] default value in table field
Author Helen Borrie
At 08:36 AM 04-06-01 +0000, you wrote:
>Nando, Helen
>NFILE_UP is a secondary field I use only for some checks or for set
>order sequence.
>I am looking for a solution that allow me to don't worry with
>calculated fields into the application. So I thought to charge
>Database to do it for me.
>I constructed Before_Insert and Before_Update triggers :
>NEW.nfile_up := Upper(New.nfile) and following SQL instruction :
>Insert into Finfile (nfile,des60) values ('Customers','Customer
>Information') it works well !!
>Delphi, IBConsole, IB_WISQL ... require data for all not null fields.
>I put Default Value to cheat them , but it doesn't work.
>They don't use default value definitions.

You need to understand that database Defaults won't "cheat" client software that sees your non-nullable columns. Defaults work **only** if the server receives NULL in the defaulted column in an INSERT operation.

Delphi + IBO **can** use the server defaults if you flag the dataset's GetServerDefaults property true. However, it is costly, because the client has to query the server to get them.

It is less costly to give IBO the defaults yourself, using the attribute DEFAULT in the ColumnAttributes of the column. Or you can flag the attribute REQUIRED as false and let the SQL pass without including the column in the GetRequiredFields checking. Another alternative is to omit the column from your insert SQL and have the server populated the computed by or defaulted columns for you.

Of course, when you use a generic client like IBConsole or IB_Wisql to insert data, you do not have the benefit of customising the way the SQL parameters are handled.

>Second solution : I tried it but it doesn't work; IBO always use
>database definitions and test NFILE_UP as required.

What did you try to do?

>Finally : it seems I have to accept to fill these information into
>all applications that will post records.

You can if you want to. Or, even better, try to understand better how the database handles non-nullable columns and how IBO can help you to customise it exactly as you want it.


All for Open and Open for All
InterBase Developer Initiative ยท