-- Modify the last number
alter sequence SQ_PRUEBA increment by 1499 nocache;
select SQ_PRUEBA.nextval from dual;
alter sequence SQ_PRUEBA increment by 1 nocache;
declare
LastValue integer;
begin
loop
select SQ_PRUEBA.currval into LastValue from dual;
exit when LastValue >= 1500 - 1;
select SQ_PRUEBA.nextval into LastValue from dual;
end loop;
end;
/
alter sequence SQ_PRUEBA increment by 1 cache 20;
Hola
Cuando le pedi a Pl/sql developer hacer algo asi me genero el codigo que te muestro arriba. Ojala te de pistas y te ayude a hacer el cambio.
declare
nMiSecuencia number(7);
begin
Select max(campo)
into nMiSecuencia
from miTabla;
-- El Drop previo solo en el caso de ya existir la Secuencia
execute immediate 'drop sequence SEQ_MIA';
execute immediate 'create sequence SEQ_MIA start with '||to_char(nMiSecuencia);
end;
/
Si no te entendi mal, necesitabas insertar un "Create Sequence" en PLSQL para hacerlo dependiente del valor de un campo de un tabla. Usa Sql Dinámico y ya esta.