Subject Re: [firebird-support] New auto-increment column, existing data
Author setysvar
Den 15.11.2016 20:58, skrev 'Some One' anotherpersonsomewhere@...
> I am trying to add new auto-increment primary keys for existing table.
> This is what I have:
> ======================================
> set term ~ ;
> execute block
> as
> declare dbkey char(8);
> begin
> for
> select rdb$db_key
> from mytable
> into :dbkey
> do
> begin
> ...
> end
> end~
> set term ; ~
> ======================================
> This fails with error "malformed string", it looks like either rdb$db_key does not match char(8) or maybe it is related to same character set settings. Any suggestions?
> It also seems that when new entries are added the auto-incremented values will start from 0, causing conflicts. Is it ok to simply right click the generator in FlameRobin, select "set value" and enter a value higher than the highest existing or will that cause any trouble?
Page 9 and 10 of
has a few interesting tips, one of them involving db_key. So maybe

declare dbkey char(8) CHARACTER SET OCTETS;

is the simplest answer to your question.

SELECT GEN_ID(<generator_name>, <a value greater than or equal to 0>)

should be a safe way to alter a sequence. I thought ALTER SEQUENCE also
was fine, but looking at, there is
a serious warning with no explanation.