Den 15.11.2016 20:58, skrev 'Some One' [email protected] [firebird-support]: > 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 http://www.firebirdsql.org/file/community/conference-2014/pdf/22_tips_firebird_system_tables.pdf 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>) FROM RDB$DATABASE should be a safe way to alter a sequence. I thought ALTER SEQUENCE also was fine, but looking at http://www.firebirdsql.org/refdocs/langrefupd20-alter-seq.html, there is a serious warning with no explanation. HTH, Set
