2 Replies Latest reply: Apr 28, 2014 3:19 PM by Ora-aff RSS

    currval and nextval strange behaviour on apex.oracle.com

    Ora-aff

      I am using SQL workshop available on apex.oracle.com.

       

      I create a sequence named: emp_SK

       

      Create sequence emp_SK;

       

      I use this sequence to add few records into employees table. I log out and log in again. Then I issue:

       

      Select emp_sk.currval from dual;

       

      It gives me an error: currval not yet defined in this session. I can understand this because I am referencing currval before referencing nextval in my session.

       

      Then I issue:

       

      Select emp_SK.currval, emp_SK.nextval from dual;

       

      It gives me output as 8 for both the columns

       

      Then i again issue the following statement in the same session

       

      Select emp_SK.currval from dual;

       

      I get the same error : currval not yet defined in the session.

       

      Why it is giving me an error? Did not I just referenced the nextval?

        • 1. Re: currval and nextval strange behaviour on apex.oracle.com
          fac586

          Ora-aff wrote:

           

          I am using SQL workshop available on apex.oracle.com.

           

          I create a sequence named: emp_SK

           

          Create sequence emp_SK;

           

          I use this sequence to add few records into employees table. I log out and log in again. Then I issue:

           

          Select emp_sk.currval from dual;

           

          It gives me an error: currval not yet defined in this session. I can understand this because I am referencing currval before referencing nextval in my session.

           

          Then I issue:

           

          Select emp_SK.currval, emp_SK.nextval from dual;

           

          It gives me output as 8 for both the columns

           

          Then i again issue the following statement in the same session

           

          Select emp_SK.currval from dual;

           

          I get the same error : currval not yet defined in the session.

           

          Why it is giving me an error? Did not I just referenced the nextval?

          Yes, but you're not using the same session: APEX uses connection pooling.

          • 2. Re: currval and nextval strange behaviour on apex.oracle.com
            Ora-aff

            Thank you for the link.