I need to initialise a new Firebird generator / sequence to the max primary key value of an existing, 'old' table. I tried the following but it is not working, I get the error "Token unknown - line 6, column 8 select". I cannot do this manually as it must be executed on many different DBs. I am using Firebird 2.5.1.
According to http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25-execblock.html this should work - what am I doing wrong?
set term #;
execute block
as
declare i int = 0;
begin
i = select max(ID) from OrganizationType_OLU;
alter sequence OrganizationType_OLU restart with :i;
end
#
set term ;#