Trying to create a sequence in Oracle that starts with the max value from a specific table. Why does this not work?
CREATE SEQUENCE transaction_sequence MI
use dynamic sql
BEGIN DECLARE maxId NUMBER; BEGIN SELECT MAX(id)+1 INTO maxId FROM table_name; execute immediate('CREATE SEQUENCE sequane_name MINVALUE '||maxId||' START WITH '||maxId||' INCREMENT BY 1 NOCACHE NOCYCLE'); END; END;