Subject Re: [firebird-support] Renumbering records
Author Martijn Tonies
> I need to "renumber" records in a table according to some "grouping"
> fields, and I though of doing it with this stored procedure:
>
> ----------
> CREATE PROCEDURE RENUM (
> SIFKOR VARCHAR(10),
> GOD INTEGER,
> ORGJ SMALLINT,
> START INTEGER)
> AS
> DECLARE VARIABLE D DATE;
> DECLARE VARIABLE N INTEGER;
> begin
> select gen_id(tmp$gen, 0) from rdb$database into :n;

Side note:

n = gen_id(tmp$gen, 0);

works fine as well. There's no need for the SELECT here.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com