Subject Re: [IBO] Retrieving generator values
Author Martijn Tonies
> CREATE PROCEDURE GET_GENERATOR_VALUE
> (
> GENERATOR_NAME VARCHAR(31)
> )
> RETURNS
> (
> GENERATOR_VALUE BIGINT
> )
> AS
> declare variable stmt varchar(60) = '';

A quick note, "60" seems a bit too short, given that:
select gen_id (,1) from rdb$database

is already 40 characters :-)

> BEGIN
> if (generator_name is not null) then
> begin
> stmt = 'select gen_id (' || generator_name || ', 1) from
rdb$database';
> execute statement (stmt) into :generator_value;
> SUSPEND;
> end
> END

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com