Subject Re: [firebird-support] PSQL to update generator value by using another generator value?
Author unordained
Agh! Bad formatting, bad.

Intended link: http://www.firebirdsql.org/pdfmanual/Firebird-Generator-Guide.pdf (page 7)

Intended code:

SET GENERATOR name TO value;

-or-

declare variable x integer;
declare variable newval integer;
begin
newval = 73; -- new desired generator value, from whatever source
x = gen_id(gen_test_1, 0); -- get current value without modifying it.
x = gen_id(gen_test_1, -x); -- get the result of setting it back to zero.
x = gen_id(gen_test_1, newval); -- re-increment to new desired value
end

-Philip

---------- Original Message -----------
From: "unordained" <unordained_00@...>
To: firebird-support@yahoogroups.com
Sent: Mon, 21 Apr 2008 10:16:12 -0500
Subject: Re: [firebird-support] PSQL to update generator value by using another generator value?

> Please see the firebird generator guide, page 7.You can modify the value of a generator via "SET
GENERATOR name TO value", but you could also do the following (pure DML):declare variable x
integer;declare variable newval integer; begin newval = 73; -- new desired generator value, from
whatever sourcex = gen_id(gen_test_1, 0); -- get current value without modifying it. x =
gen_id(gen_test_1, -x); -- get the result of setting it back to zero. x = gen_id(gen_test_1,
newval); -- re-increment to new desired value end(My quick test shows this resulted in the right
value; gen_test_1 had a value of 73 when tested via gen_id(gen_test_1, 0) after running this SP
chunk.)Note that you'll want to be sure you're doing this in single-user mode, given that anybody
else messing with the generator at the same time will throw it off!(my apologies if my email client
makes a mess of this, I've been having trouble with it recently)-Philip
>
> ---------- Original Message -----------
> From: "william_yuwei" <william_yuwei@...>
> To: firebird-support@yahoogroups.com
> Sent: Mon, 21 Apr 2008 14:31:13 -0000
> Subject: [firebird-support] PSQL to update generator value by using another generator value?
>
> > HI, All
> >
> > Is there any PSQL that can modify a generator value by using another
> > generator value? What I want to do is to initial a new created
> > generator value by using another generator value in a script, that my
> > customers can just run this script to update their databases.
> >
> > Thanks
> >
> > William
> >
> >
> ------- End of Original Message -------
>
> [Non-text portions of this message have been removed]
>
>
------- End of Original Message -------