Subject Re: [firebird-support] Re: Is some API to get generator value?
Author Ann Harrison
> --- In firebird-support@yahoogroups.com, "karolbieniaszewski" <liviuslivius@...> wrote:
>>
>> is some API to get generator value?
>> or only possible way is
>> select GEN_ID(gen_name, 0) from RDB$Database
>>
>> i ask because this is stupid to start transaction to get non transactional object value


On Mon, Apr 11, 2011 at 3:56 PM, emb_blaster <EMB_Blaster@...> wrote:

>  AFAICR, no. There's not.
>
>  If you are using ISQL, you could use "SHOW GENERATOR xxxxx;" or "SHOW SEQUENCE xxxxxx;", or yet "SHOW GENERATORS;" or "SHOW SEQUENCES;" to list all. (see http://www.firebirdsql.org/refdocs/langrefupd21-ddl-sequence.html)

Any of those statements will either open a transaction or use the DDL
transaction.
>
>  Also, I can agree that seems make no sense at all that. But I've learned to do not call stupid something I did not understand at all. Maybe in the time it was made, a "no transaction request" would make no sense too.
> So, if someone else could explain, I would be glad to learn too. But don't think this is a bug or a missing feature at all. :)
>

Since you can neither write nor read the contents of the database
without an open
transaction, it may be that the designers assumed that there would be
a transaction
started or about to start when someone wanted the current contents of
a generator.
Note that in a multi-user application, the value returned by GEN_ID
(<generator>,0)
may well not be the value most recently stored by the transaction that
gets the value.

Good luck,

Ann