Oracle sequence parameters: nextval and currval. Nextval returns the next avaiable sequence value. it returns a unique value every time it is referenced, even for different users. currval obtains the current sequence value. open the first session and create a sequence: Call the nextval value before calling the value of currval.
SQL> create sequence myseq1 increment by 10 start with 120 maxvalue 9999 nocache nocycle;Sequence created.SQL> select myseq1.currval from dual;select myseq1.currval from dual *ERROR at line 1:ORA-08002: sequence MYSEQ1.CURRVAL is not yet defined in this session
Therefore, call the nextval value first. The first value is 120.
SQL> select myseq1.nextval from dual; NEXTVAL---------- 120
Open the second session and the value of calling nextval will continue to increase to 130.
SQL> select myseq1.nextval from dual; NEXTVAL---------- 130
Return to the first session and call the value of currval,
SQL> select myseq1.currval from dual; CURRVAL---------- 120
We can see that the value of currval is not 130, or the value of the previous session. The value of nextval is called,
SQL> select myseq1.nextval from dual; NEXTVAL---------- 140
We can see that the value of nextval is added based on the second session. Therefore, the value of nextval is added every time it is called. The value of currval is the same as the current value of its own session.