I have a huge Firebird database with a table that counts 41 millions of rows. Recently I have added a new float column and would like to fill it with incremental data. Each next value should be a previous incremented by RAND(). The very first value is also RAND().
How to do this?
The query
SELECT ID FROM MY_TABLE WHERE MY_COLUMN IS NULL ROWS 1;
takes up to 15 seconds so I wouldn't count on this query executed in a loop.
The table has an indexed ID column which is a part of composite primary key.
Use something like
SEQUENCE(GENERATOR) in the Language Reference.GEN_IDfunction to forward a generator for a specified number of integer unitsAlternatively use a stored procedure or EXECUTE BLOCK (or https://firebirdsql.su/doku.php?id=execute_block)
Something like
Or you may try using cursors, but I did not try so I do not know for sure how it would work, see also
FOR SELECT.