Subject Re: [ib-support] Re: Inserting new record and using a unique generated number - help
Author Helen Borrie
At 07:15 PM 02-07-01 +0000, you wrote:
>
> > Once the transaction starts,
>nothing that happens on the client gets written into the database
>until that unit of work gets committed.
> >
>
>So I could use a transaction on the Trigger (from memory - I'm at wok
>writting this <g> there is a option to use transaction in the
>declaration of the trigger) would this then solve the problem of not
>seeing the value on the screen ?

No. At the time the trigger fires, the statement is within a transaction. The transaction will not be committed (and, thus, its work made visible to other transactions) until after all the triggers have finished their tasks). One transaction cannot start another transaction.

If "not seeing the value on the screen" is a problem, you can fetch the generator before the transaction physically starts, via a separate transaction. Generators are handy this way, since they are not controlled by transactions (although you do need to be in a transaction to get the next value). Because the numbers are not recycled, there is no risk of anyone else getting the same number.

Development tools are more or less useful about helping to get the generator numbers "ahead of time". IB Objects (a very powerful set of connectivity components for use with Delphi and Borland C++Builder) actually lets you define the "generator links" for every column in the database that uses one.

Cheers,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________