1
我想在oracle 11g中使用以下過程動態地將序列重置爲1。在oracle 11g中的重置序列
create or replace
procedure reset_sequence(p_seq in varchar2)
is
l_value number;
begin
-- Select the next value of the sequence
execute immediate
'select ' || p_seq ||
'.nextval from dual' INTO l_value;
-- Set a negative increment for the sequence,
-- with value = the current value of the sequence
execute immediate
'alter sequence ' || p_seq ||
' increment by -' || l_value || ' minvalue 0';
-- Select once from the sequence, to
-- take its current value back to 0
execute immediate
'select ' || p_seq ||
'.nextval from dual' INTO l_value;
-- Set the increment back to 1
execute immediate
'alter sequence ' || p_seq ||
' increment by 1 minvalue 0';
end;
/
但是,當我試圖執行重置序列circle_seq的過程中,我收到以下錯誤
BEGIN reset_sequence(vf_circle_seq); END;
*
ERROR at line 1:
ORA-06550: line 1, column 22:
PLS-00357: Table,View Or Sequence reference 'CIRCLE_SEQ' not allowed
in this context
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
什麼是錯誤的代碼?這在oracle 11g中是不可能的,因爲在它工作正常之前,我在oracle 10g中使用了相同的代碼。
嘗試'BEGIN reset_sequence( 'vf_circle_seq')通過; END;' – haki
是的。它運行良好。我犯了錯誤。謝謝! – Mohan
我會把它作爲回答 – haki