Subject RE: [firebird-support] reading a generator value in a stored procedure
Author Thomas Steinmaurer
> here is my way to read a value from a generator
> in a stored procedure (this is only a part of the SP):
>
> DECLARE VARIABLE NUM_VALUE NUMERIC (18, 0);
>
> /* Procedure body */
> execute statement ( 'select gen_id(' || :gen_name ||
> ', 1)FROM rdb$Database' ) into :NUM_VALUE;
>
> I wonder if there is an easier way???
>

If you supply the name of the generator via an input
parameter, then EXECUTE STATEMENT is the only way.

If your generator name is static, then you can use:

BEGIN
NUM_VALUE = GEN_ID(YOUR_GEN, 1);
END


HTH,
Thomas Steinmaurer

LogManager Serie - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database and MS SQL Server
Upscene Productions
http://www.upscene.com