Home » SQL & PL/SQL » SQL & PL/SQL » Sequence ora-8002 error for every connection. (Oracle 12, Linux)
Sequence ora-8002 error for every connection. [message #626453] Tue, 28 October 2014 03:11 Go to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

I am using sequence in Oracle 12c on linux within schema sngadmin and given grant to etos_user.


CREATE SEQUENCE SNGADMIN.TEST
  START WITH 1
  MAXVALUE 1000
  MINVALUE 1
  NOCYCLE
  NOCACHE 
  NOORDER
  NOKEEP
  GLOBAL;


GRANT SELECT ON SNGADMIN.TEST TO ETOS_USER;



When selecting from sngadmin sequence within schema its asking for nextval before every currval for every connection.

04:05:19 nsatvznp[SNGADMIN]> connect sngadmin
Enter password:
Connected.
04:05:32 nsatvznp[SNGADMIN]>
04:05:32 nsatvznp[SNGADMIN]> select sngadmin.test.currval from dual;
select sngadmin.test.currval from dual
*
ERROR at line 1:
ORA-08002: sequence TEST.CURRVAL is not yet defined in this session


Elapsed: 00:00:00.00
04:05:39 nsatvznp[SNGADMIN]> select sngadmin.test.nextval  from dual;

   NEXTVAL
----------
         1

Elapsed: 00:00:00.01
04:05:52 nsatvznp[SNGADMIN]> select sngadmin.test.currval from dual;

   CURRVAL
----------
         1

Elapsed: 00:00:00.00
04:06:07 nsatvznp[SNGADMIN]> disconnect
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
04:06:18 nsatvznp[SNGADMIN]> connect sngadmin
Enter password:
Connected.
04:06:35 nsatvznp[SNGADMIN]>
04:06:35 nsatvznp[SNGADMIN]> select sngadmin.test.currval from dual;
select sngadmin.test.currval from dual
*
ERROR at line 1:
ORA-08002: sequence TEST.CURRVAL is not yet defined in this session


Elapsed: 00:00:00.01
04:06:40 nsatvznp[SNGADMIN]>



if for some reason I need to know only what is the currval is for sequence, how Can we get that w/o running nextval.

Thanks.
Re: Sequence ora-8002 error for every connection. [message #626456 is a reply to message #626453] Tue, 28 October 2014 03:24 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
That is the correct resulr: currval is the last value issued in your session.

As you have defined it with NOCACHE, you could query ALL_SEQUENCES to get the next value to be issued and subtract 1, but that would be a pretty bad design.
Re: Sequence ora-8002 error for every connection. [message #626458 is a reply to message #626453] Tue, 28 October 2014 03:32 Go to previous message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

As explained in the documentation: How to Use Sequence Values

Quote:
Before you use CURRVAL for a sequence in your session, you must first initialize the sequence with NEXTVAL.


Previous Topic: join query
Next Topic: Create partitioned table
Goto Forum:
  


Current Time: Thu Apr 25 18:29:15 CDT 2024