Subject Re: [firebird-support] List of Tables & Generators
Author Helen Borrie
At 07:17 PM 12/03/2004 -0500, you wrote:

>Hello all,
>
>I would like to have a way to completely clear out a database of all
>data and reset all of the generators. Would it be possible to get a SQL
>example or a pointer where I can get an example of retrieving that info
>from FB 1.5 final?
>
>Thanks a bunch!

It's easier than you think (I think).

Make a metadata-only gbak backup, restore it, and you're nearly done. The
generators will come through with their existing values. You can write a
script to zero them:

...
SET GENERATOR GEN_01 TO 0;
SET GENERATOR GEN_02 TO 0;
...

Or keep a SP definition on hand that you can add and drop as required:

CREATE PROCEDURE RESET_ALL_GENERATORS
AS
DECLARE VARIABLE GEN_NAME CHAR(31) DEFAULT '';

BEGIN
FOR SELECT RDB$GENERATOR_NAME FROM RDB$GENERATORS
WHERE RDB$GENERATOR_NAME NOT STARTING WITH 'RDB$'
INTO :GEN_NAME
DO
EXECUTE STATEMENT
'SET GENERATOR '||CAST(GEN_NAME AS VARCHAR(31))||' TO 0';
END ^

/hb