Link to home
Start Free TrialLog in
Avatar of sakthikumar
sakthikumar

asked on

Sequence does not exists.

I have a sequence in remote DB. I am able to access the sequence (get nextval)
from a normal query in sql window, but I am not able to access it inside a procedure.

I am using the same username for querying and for procedure.

For procedure, I am getting sequence does not exists.

What could be the reason?
Avatar of chaau
chaau
Flag of Australia image

Does the procedure exist in the same schema? If not, you can access your sequence like this:
schema.sequence.NEXTVAL

Open in new window

Hi,
1. make sure the relevant DB link is working fine
2. ensure you have been granted with the privileges to use this sequence
Avatar of sakthikumar
sakthikumar

ASKER

Hi all
I am sorry, sequence is in the same DB only.

But I was having the public synonym. using that I can query in sql window, but not able to use it inside procedure.

What could be the reason.?
Is the synonym granted to you? How about to directly refer to the sequence name instead?
For procedure, I am getting sequence does not exists.

when do you get this error, at compile time or runtime?!
SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It may be that you have permissions on the sequence through a role, which is not carried over in a procedure. Try adding the AUTHID CURRENT_USER clause in your procedure declaration -
Ex.
create or replace procedure myproc(params in datatypes)
authid current_user as
...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am not able to find the correct answers, but these are some good useful infos.
Can you provide your DBMS version, and the relevant portion for the package?
My guess is the correct solution was the first one selected.

It is likely a GRANT issue.  The GRANT needs to be given directly and not through a ROLE.