Subject Re: Firebird_2 - Zeos_dbo 6.5.1 - "alter sequence"
Author Svein Erling Tysvær
Hi Gianni!

Is 'alter sequence' a valid command in Firebird? There are (at least)
two other ways to do this, the one I would recommend would be:

select gen_id(sss, 7777-gen_id(sss,0)) from rdb$database

The above should work in most cases, though if someone simultaneously
got the next value, I wouldn't bet on the generator not getting the
value 7778.

HTH,
Set

--- In firebird-support@yahoogroups.com, "giannifilippone" wrote:
>
> Hello Group,
> can anyone solve a doubt ?
> I'm using FB2+Zeos, all is OK & easy if I use TZsequence
> with normal autoinc.
> But I cannot re_set the generator number; my code here :
>
> conn1.starttransaction;
> SQL.Clear;
> SQL.Add('alter sequence sss restart with 7777');
> ExecSQL;
> conn1.commit;
>
> conn1.starttransaction;
> SQL.Clear;
> SQL.Add('INSERT into my_table ');
> SQL.Add('(cod, descr)');
> SQL.Add('values (:cod, :descr)');
> ParambyName('cod').AsInteger := sss.GetNextValue;
> ParambyName('descr').Asstring:= 'xxxx'+inttostr
> (sss.GetCurrentValue);
> ExecSQL;
>
> conn1.commit; >>>>> the new value 7777 is ignored and generator
> continues incrementing the old value !!?? <<<<<<<<<<<<<<<
>
> Many thanks in advance & regards,
> Gianni Filippini