Sequence does not exist ORA-02289

I have a problem getting my SEQUENCE. I created the sequence as an administrator and gave the ability to select and change privileges to another user.

CREATE SEQUENCE  "OWNER"."TOT_SEQ"  MINVALUE 1000 MAXVALUE 1000000000 INCREMENT BY 1 START WITH 1000 CACHE 20 NOORDER  NOCYCLE ;

grant select,ALTER on TOT_SEQ to user;
commit;

      

When I do this:

select sequence_name from all_sequences;

TOT_SEQ

      

I see my SEQUENCE on the list.

But I cannot access the sequence in my code. using:

select <SEQUNCE_name>.nextval from dual;

      

What am I doing wrong?

+3


source to share


3 answers


You need to either fully qualify your sequence with:

SELECT <owner>.<sequence name>.nextval FROM dual;

      



Or create a generic synonym for it:

CREATE PUBLIC SYNONYM TOT_SEQ for OWNER.TOT_SEQ;
SELECT TOT_SEQ.nexval FROM DUAL;

      

+4


source


Have you tried using the fully qualified name in your code?

select <owner>.<SEQUNCE_name>.nextval from dual;

      



If you already have, can you edit the question to post the output of the following commands. "OWNERS", "USER" in your examples are a little confusing.

select the sequence, owner from all_sequences, where sequence_name = 'TOT_SEQ'; select grantor, table_name, privilege from all_tab_privs, where sequence_name = 'TOT_SEQ';

+1


source


Make sure you create an uppercase sequence even if you use lowercase in a trigger / select statement.

+1


source







All Articles