Subject Re: [firebird-support] Initializing Generators in Stored Procs
Author Helen Borrie
At 11:44 AM 18/09/2003 +0200, you wrote:
>How do I do the following ?:
>
>CREATE PROCEDURE INITIALIZE_TRANSTYPES
>AS
>BEGIN
> SET GENERATOR "GEN_TXNTYPE" TO 0;
>END
>
>When I try to create the Stored Procedure, I get the following error :
>
>SQL error code = -104
>Token unknown - line 4, char 4
>SET
>Statement: CREATE PROCEDURE INITIALIZE_TRANSTYPES
>AS
>BEGIN
> SET GENERATOR "GEN_TXNTYPE" TO 0;
>END

Try this:
CREATE PROCEDURE INITIALIZE_TRANSTYPES
AS
DECLARE VARIABLE OLD_GEN BIGINT;
DECLARE VARIABLE NEW_GEN BIGINT;
BEGIN
OLD_GEN = GEN_ID("GEN_TXNTYPE", 0);
NEW_GEN = GEN_ID("GEN_TXNTYPE", (-1 * :OLD_GEN));
END

But Oh! don't do it except on a completely shut-down database.

h.