Subject Re: To Geoff, [IBO] DSQL question
Author Geoff Worboys
Hi Nico,

> I'm just thinking something. In the pre insert
> trigger I still do some field validation. What if an error
> occurs in the trigger, or the user cancels his insert, I
> guess that's one generator number wasted ?? Should I
> do the checking on the client, to avoid that a record is
> refused by the server ?

Yes, generator numbers get wasted quite frequently. This is less of
an issue now that IB6 uses 64bit integers - it will take a VERY long
time to run out of values.

If you use the GeneratorLinks property of the IBO dataset or
connection to assign newly created key values at the client, and setup
your insert triggers to only generate new values if the key is null,
then when a validation exception occurs at the server the user will
get a chance to correct their mistakes and try again - still using the
same generated value that IBO originally retrieved. The number will
not be lost unless the user cancels or rolls back the insert.

Generated key values can provide a great deal of optimisation since
the value, once created, need never be changed and so never needs
cascading to all the relations. Because the generated key values can
get quite large, and because you never want to change them if you can
avoid it, it is best if the values are never seen or used by the
client (except as key fields in the IBO dataset definition).

I do not even reuse generated key values for "account number" fields.
I maintain a totally separate and independant generated field for this
purpose - it makes maintenance a lot easier in some situations.


By default IBO checks for required fields (CheckRequired property)
before trying to post. There are some validations that can only be
conveniently done at the client - particularly any requiring in
interactive action, such as mask processing. However it is generally
considered good practise to implement whatever validation is
possible/practical into server triggers, so that such validation will
be applied regardless of the application used to access the database.

I dont know if any of this helps.

Geoff Worboys
Telesis Computing