Subject Re: [firebird-support] Getting the current value of a sequence using new syntax
Author Helen Borrie
At 05:21 AM 15/02/2008, you wrote:
>Hell folks,
>
>I was wondering if there is an alternative to GEN_ID(seq_name, 0) for
>the new sequences syntax introduced in Firebird 2.0+

No; but I'm curious to know why you need it - just because some people (unwisely) think they will massage the current (= latest-generated) value in some way, under the misapprehension that this practice is multi-transaction-safe. That's a no-no, unless you're writing the *only* application that will ever access your database *and* it's for stand-alone deployment *and* your application is written in such a way as to totally serialise everything.

You can, however, "grab" the NEXT value into your application and work with it safely, provided you don't have any INSERT or UPDATE triggers around that arbitrarily overwrite supplied NEW.primarykey or serial number values. Once a sequence number is generated it is never generated again (unless one foolishly messes around with its starting value, of course!)

./heLen