Subject | [IBO] Re: Default values not defaulting (newbie) |
---|---|
Author | bhatakeyama |
Post date | 2002-04-11T16:53:56Z |
My apologies, I'm either not understanding or I have a different
view of how defaults are handled with Server defaults.
But first, I did some testing with the both TIBOQuery/TIBODatabase
and TIB_Query/TIB_Database. With the latter I was able at runtime to:
IB_Database->GetServerDefaults= true;
IB_Query->Insert();
IB_Query->FieldByName("RecNum")= i;
IB_Query->Post();
IB_Database->Commit();
and this correctly set 'SortFlag' automatically with the default value
I defined on the server, which is exactly what I want.
But, because I'm trying to port my code and am trying to use
TIBOQuery, I tried to access a 'GetServerDefaults' property but
was not successful. I also tried to use a TIB_Connection component.
IBODatabase->GetServerDefaults= true;
IB_Connection->GetServerDefaults= true;
both failed with the compiler indicating that GetServerDefaults is not
a member of the respective classes.
Am I missing something?
With regards to methods of handling defaults, am I correct
in understanding that you set all your defaults in your
client application and you do not define default values
when you create your database tables? If so, then we
just disagree in philosophy.
bhata
view of how defaults are handled with Server defaults.
But first, I did some testing with the both TIBOQuery/TIBODatabase
and TIB_Query/TIB_Database. With the latter I was able at runtime to:
IB_Database->GetServerDefaults= true;
IB_Query->Insert();
IB_Query->FieldByName("RecNum")= i;
IB_Query->Post();
IB_Database->Commit();
and this correctly set 'SortFlag' automatically with the default value
I defined on the server, which is exactly what I want.
But, because I'm trying to port my code and am trying to use
TIBOQuery, I tried to access a 'GetServerDefaults' property but
was not successful. I also tried to use a TIB_Connection component.
IBODatabase->GetServerDefaults= true;
IB_Connection->GetServerDefaults= true;
both failed with the compiler indicating that GetServerDefaults is not
a member of the respective classes.
Am I missing something?
With regards to methods of handling defaults, am I correct
in understanding that you set all your defaults in your
client application and you do not define default values
when you create your database tables? If so, then we
just disagree in philosophy.
bhata
--- In IBObjects@y..., "Helen Borrie (TeamIBO)" <helebor@t...> wrote:
>
> At 06:08 AM 11-04-02 +0000, bhata wrote:
>
> >I am using IBOQuery with the latest IBO4Gc. I looked at the TI
sheet
> >but didn't see any reference to ColumnAttributes or
InternalDataset.
>
> InternalDataset, no, because this is simply the TIB_BDataset that
wraps
> around the TIBOQuery. You can access (relevant) properties of this
wrapper
> through InternalDataset...including ColumnAttributes. You can get
at
> DefaultValues through your IBODatabase object's DefaultValues: just
> include the table identifier...so, for example
>
> aTable.SomeColumn='I am a default value'
>
> >If I understand you correctly, if I use Insert() TIBOQuery will
> >either send a NULL or a value I set in DefaultValues.
>
> If you use the standard Insert(), yes. You can cause the insert
statement
> to be whatever you like by setting a custom statement in the
InsertSQL
> property - then IBO will use that instead of composing one itself
based on
> the Fields[] array.
>
> >Doesn't this
> >defeat the ability to have the server set the default values?
>
> "Defeat"? Hardly. If you want to, you can compose your own
insertsql and
> have the server exercise the constraints without intervention from
the
> client. However, since Delphi/IBO or any client development
software
> doesn't know about most of the server constraints, your app program
has to
> be aware of it.
>
> With IBO, you can use the ib_connection's GetServerDefaults property
to
> make IBO query the server for them. All very well in concept, but
it means
> an extra query = more network overhead. So IBO helps you by letting
you
> install the defaults on the client side and thus avoid that
overhead.
>
> If you have been used to desktop databases, it's a bit of mindshift
to get
> used to a client/server database being a kind of remote, abstract
beast
> that communicates with applications only at arm's length. Clients
have to
> send messages to the server (through the client library gds) and,
having
> done so, they have to react to messages sent back by the server.
>
> What IBO does for you is to provide ways to pre-empt error
conditions, if
> you want to. On a network, this is generally preferable to waiting
for the
> error to occur and then reacting to it.
>
> >The field that I am having problems with is defined as:
> > SMALLINT DEFAULT 0 NOT NULL
>
> Then just lodge the default value in the DefaultValues array and
forget
> about it from here on.
>
> That doesn't mean you should simply bypass the server-based
> attributes. They provide backup to ensure that the constraints are
met
> regardless of where new data and changes originate from.
>
> regards,
> Helen Borrie (TeamIBO Support)