Home >Database >Mysql Tutorial >ORA-08002: 序列 SEQ_WGB_TEST2.CURRVAL 尚未在此会话中定义

ORA-08002: 序列 SEQ_WGB_TEST2.CURRVAL 尚未在此会话中定义

WBOY
WBOYOriginal
2016-06-07 17:28:442239browse

ORA-08002: 序列 SEQ_WGB_TEST2.CURRVAL 尚未在此会话中定义

环境

Oracle 11.2.0 + SQL Plus

问题

查询Sequence的当前值出现以下错误:

SQL> SELECT seq_WGB_Test2.CURRVAL FROM dual;

SELECT seq_WGB_Test2.CURRVAL FROM dual

      *
第 1 行出现错误:

ORA-08002: 序列 SEQ_WGB_TEST2.CURRVAL 尚未在此会话中定义

解决

首先创建一个测试序列:

SQL> CREATE SEQUENCE seq_WGB_Test2
  2  INCREMENT BY 1
  3  START WITH 1000;

序列已创建。

然后查询当前值:

SQL> SELECT seq_WGB_Test2.CURRVAL FROM dual;
SELECT seq_WGB_Test2.CURRVAL FROM dual
      *
第 1 行出现错误:
ORA-08002: 序列 SEQ_WGB_TEST2.CURRVAL 尚未在此会话中定义

调用NEXTVAL后再次查询当前值:

SQL> SELECT seq_WGB_Test2.NEXTVAL FROM dual;

  NEXTVAL
----------
      1000

SQL> SELECT seq_WGB_Test2.CURRVAL FROM dual;

  CURRVAL
----------
      1000

SQL>

创建Sequence后直接查询它的当前值(CURRVAL)会出错,,要先调用Sequence对象.NEXTVAL,才能查询当前值。注意:Oracle是不区分对象名大小写的。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn