Subject Re: Generators don't works anymore
Author amoradell
Arghh !

thanks for the correct syntax ;)

also to mimic isql show generators in sql
I declare genvalue as bigint, but it works also with integer

set term ^;
create or alter procedure show_generators returns (genname
varchar(31), genvalue bigint)
as
begin
for select rdb$generator_name from RDB$GENERATORS
where (rdb$system_flag is null or rdb$system_flag=0) into :genname do
begin
execute statement 'select gen_id('||:genname||',0) from
rdb$database' into :genvalue;
suspend;
END
end
^
set term ;^

select * from show_generators

thanks

Alexandre
--- In firebird-support@yahoogroups.com, Aage Johansen <aagjohan@...>
wrote:
>
> amoradell wrote:
> > Hi,
> >
> > 1 - select (gen_comuni_id,0) from rdb$database : value
> > 2 - insert record in columni without value for mycode
> > 3 - select (gen_comuni_id,0) from rdb$database : value
> > should have changed !
> >
>
> Your selects cannot work - wrong syntax.
>
> However:
> gen_id(gen_comuni_id,0) will always give the current
> value of gen_comuni_id.
> gen_id(gen_comuni_id,1) will increase the value and
> return the new value.
>
> try
> select gen_id(gen_comuni_id,1) from rdb$database
> a couple of times - the value should increase by 1 for every call.
>
> If your program doesn't work, the probable reason is that the trigger
> is never - well - "triggered".
>
>
> --
> Aage J.
>