如何将序列中的下一个值转换为变量? [英] How do you get the next value in a sequence into a variable?
本文介绍了如何将序列中的下一个值转换为变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我正在编写存储过程,并且在将序列的下一个值转换为变量时遇到麻烦.
So I'm writing a stored procedure and am having trouble getting the next value of a sequence into a variable.
序列名称被传递到函数中并存储为varchar2
变量.如何将该序列中的下一个值转换为局部变量.
The sequence name is passed into the function and is stored as a varchar2
variable. How can you get the next value in that sequence into a local variable.
推荐答案
像这样吗?
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;
这篇关于如何将序列中的下一个值转换为变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文