Subject | RE: [firebird-support] reading a generator value in a stored procedure |
---|---|
Author | Thomas Steinmaurer |
Post date | 2004-02-18T17:41:36Z |
> here is my way to read a value from a generatorIf you supply the name of the generator via an input
> 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???
>
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