sqloracle-databaset-sqloracle10gsequence-sql

sequence already created but error showing RA-02289: sequence does not exist


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.


Solution

  • 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