Subject Re: [firebird-support] Generator only seems to increment once...?
Author Helen Borrie
At 09:58 a.m. 27/04/2015, brian brian@... [firebird-support] wrote:

>Hi folks,
>
>Has anything changed with regard to generators after Firebird 1.5?
>I've got Helen Borrie's first version as my reference book, and in
>there I read
>
>SELECT GEN_ID(<name>,<step>) FROM RDB$DATABASE;
>
>as the way to increment the value returned from a generator.
>
>I guess I should say now that I'm using the embedded server v2.5.2
>from Lazarus/FreePascal under 64-bit Debian.
>
>Everything else seems to be working, I can create the database, the
>tables, the indices, all works fine, but when I try to return values
>from the generator it never increments. I can vary the value returned
>by varying the step, but it's always returning (1+step) no matter how
>many calls I make to the routine. Does anybody have any idea what I'm
>missing, please?

Did you actually create a generator?
Assuming you're using isql from the /bin/directory of your Firebird installation:

CREATE GENERATOR MYGEN;
COMMIT;
SELECT GEN_ID (MYGEN,1) FROM RDB$DATABASE as MyNumber;
-- repeat this a few times.


Helen Borrie, Support Consultant, IBPhoenix (Pacific)
Author of "The Firebird Book" and "The Firebird Book Second Edition"
http://www.firebird-books.net
__________________________________________________________________