Subject | [IBO] Re: Default values not defaulting for some field |
---|---|
Author | ming |
Post date | 2012-02-06T05:19:36Z |
DEAR ALL
here note ib_components.pas
{ I made it so that if NULL was declared as the default value for a column }
{ on the server that it will make it be properly applied on the client if }
{ GetServerDefaults is applied. }
{ Copyright (C) 2004 Jason Wharton }
{
may be the priority should check
default value is assigned or not,
if assigned send the default value to client app, if not assigned the value will be set the null
null value always send to client except not using "select *" but using "select field," and the field last_user not include.
my problem because i will show the field to the client
any suggestion?
thanks Hellen for answer
here note ib_components.pas
{ I made it so that if NULL was declared as the default value for a column }
{ on the server that it will make it be properly applied on the client if }
{ GetServerDefaults is applied. }
{ Copyright (C) 2004 Jason Wharton }
{
may be the priority should check
default value is assigned or not,
if assigned send the default value to client app, if not assigned the value will be set the null
null value always send to client except not using "select *" but using "select field," and the field last_user not include.
my problem because i will show the field to the client
any suggestion?
thanks Hellen for answer
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 12:00 PM 1/02/2012, ming wrote:
> >hi all
> >
> >my problem for default value still error in ibo even i use the newest ibo, any sugestion for my problem?
>
> I think you misunderstand how the Firebird/IB column default works...
> 1. It works ONLY for an insert; AND
> 2. It is not available until the record is written to disk; AND
> 3. It is not written if the column name is supplied in the column list.
>
>
> >because the trigger can be alternative but i think not eficient for every table i must add before insert for 1 field only type data varchar.
> >
> >Need solution, any body help me please...
>
> You could provide custom InsertSQL for your datasets, leaving the defaulted column out of the INSERT statement.
> *or*
> You could use the DefaultValue attribute of the field in the dataset. However, this is not ideal as it binds your application layer to the database too tightly.
> Along the same lines, if you are using domains for these columns, you can use IB_Connection.DefaultValues to provide domain_name=value strings for any application level. This still has the tight binding limitation.
>
> In my view, the Before Insert trigger is the only good solution from the point of view of data integrity. If you write it correctly, you will always get the value you want, regardless of the application. The SQL default is almost entirely useless.
>
> Why do you think it is too much work? Are you maintaining proper DDL scripts for your databases?
>
> Helen
>