有人遇到这么一个问题,访问一个序列怎么出错了,错误如下:
ORA-08002: 序列 SEQ_GX.CURRVAL 尚未在此会话中定义
这是因为在一个新的会话中,序列需要初始化,也就是通过.NEXTVAL来完成序列的初始化。
测试如下:
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as crmii
SQL>
SQL> create sequence SEQ_TEST
2 minvalue 1
3 maxvalue 999999999999
4 start with 369161
5 increment by 1
6 cache 20
7 order;
Sequence created
SQL> SELECT SEQ_TEST.CURRVAL FROM DUAL;
SELECT SEQ_TEST.CURRVAL FROM DUAL
ORA-08002: 序列 SEQ_TEST.CURRVAL 尚未在此会话中定义
SQL> SELECT SEQ_TEST.NEXTVAL FROM DUAL;
NEXTVAL
----------
369161
SQL> SELECT SEQ_TEST.CURRVAL FROM DUAL;
CURRVAL
----------
369161
SQL>
-The End-