Oracle sequence generator

How to write stored procedure,which take the sequence name as input and dynamically generates a nextval from that sequence

Questions by krishnaadapa

Showing Answers 1 - 1 of 1 Answers


  • Jul 30th, 2014

  1. CREATE OR REPLACE Procedure P_Get_Value( seqnm IN Varchar2) IS

  2.   L_Var Varchar2(100);

  3.   TYPE cur_typ IS REF CURSOR;

  4.   c cur_typ;

  5. Begin

  6.   OPEN c FOR SELECT  || seqnm ||

  7.       .NEXTVAL FROM Dual;-- USING seqnm;

  8.   Fetch c INTO L_Var;    

  9.   Close c;

  10.   dbms_output.put_line(nextvalue:  || L_var);

  11. End;

  12. ----- to execute

  13. Begin

  14.    P_Get_Value(&seqnm);

  15. End;

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions