比如,我写这样一个函数:
CREATE OR REPLACE Function GET_SEQUENCE(v_sequence in sequence)
Return number Is
v_date Varchar2(20);
Begin
return 1;
end;
但报错了:
FUNCTION GET_SEQUENCE 编译错误
错误:PLS-00201: identifier 'SEQUENCE' must be declared
行:1
文本:CREATE OR REPLACE Function GET_SEQUENCE(v_sequence in sequence)
错误:PL/SQL: Compilation unit analysis terminated
行:1
文本:CREATE OR REPLACE Function GET_SEQUENCE(v_sequence in sequence)
求教一下大大们,谢谢!
------解决方案--------------------
楼主想用一个Function通过传入一个sequence名称获取这个序列的下一个值么?
假如是这样的话,用动态sql.
CREATE OR REPLACE Function GET_SEQUENCE(v_seq_name in varchar2)
Return number Is
v_seq number;
v_sqlstr varchar2(128);
begin
v_sqlstr:='select '
------解决方案--------------------
v_seq_name
------解决方案--------------------
'.nextval '
------解决方案--------------------
' from '
------解决方案--------------------
' dual';
execute immediate v_sqlstr into v_seq;
return v_seq;
END;