Creating Sequence dynamically from table column max count

posted Mar 23, 2012, 1:30 PM by Sachchida Ojha
 DECLARE
 V_SEQ NUMBER(16);
 BEGIN
 EXECUTE IMMEDIATE 'SELECT NVL(MAX(col1),0)+1 FROM tab1' INTO V_SEQ;
 EXECUTE IMMEDIATE 'CREATE SEQUENCE tab1_col1_SEQ START WITH '|| V_SEQ || ' CACHE 20';
 END;
/
Comments