1

I created a sequence in ORACLE 10g database

CREATE SEQUENCE "test_seq" 
START WITH 1 INCREMENT BY 3 
NOMAXVALUE NOMINVALUE NOORDER NOCYCLE NOCACHE;

I also have a table in database to use this sequence

CREATE TABLE USER_TEST
(
   U_NAME   VARCHAR2 (100),
   PWD      VARCHAR2 (100),
   SR_NO    NUMBER
)
NOCACHE
LOGGING;

But when inserting values in table using

INSERT INTO USER_TEST VALUES( test_seq.NEXTVAL,'QWERTY','1QWE')

it gives following error

ORA-02289: sequence does not exist

What should I do to use my sequence inserting data to my table.If i'm not using sequence insert command works perfectly.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Anand
  • 114
  • 1
  • 2
  • 14
  • You created a sequence with a case-sensitive identifier `"test_seq"`. You then try to use a non-quoted identifier `test_req`-- that won't work. Your non-quoted identifier is also misspelled. If your `create sequence` statement is accurate, `values( "test_seq".nextval, ...` would work. But more likely you want to use case-insensitive identifiers for your sequences (and your other objects). And I'm not sure whether some of the issues are due to typos in the question you're posting. – Justin Cave Jun 15 '15 at 18:46
  • If i use `insert into USER_TEST values( "test_seq".NEXTVAL,'anand','ansrargu')` it is showing `ORA-01722: invalid number` – Anand Jun 15 '15 at 18:54

1 Answers1

3

You are using wrong seq name test_req while correct name is test_seq

INSERT INTO USER_TEST VALUES('QWERTY','1QWE',"test_seq".NEXTVAL) 

Second mistake is your insert statement is wrong, as your column name is not specified and your auto-generate field is on last in column list so you have to specify test_seq.NEXTVAL in last in insert statement

SEE Working Fiddle

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47