Oracle
 sql >> Database >  >> RDS >> Oracle

Come si ottiene il valore successivo in una sequenza in una variabile?

Qualcosa del genere?

create or replace procedure next_val (p_sequence_name varchar2)
as

v_nextval integer;
v_select varchar2(100);

begin

v_select := 'select '||p_sequence_name||'.nextval from dual';

execute immediate v_select into v_nextval;

dbms_output.put_line('Nextval is: '||TO_CHAR(v_nextval));

end;