views:

39

answers:

1

I've got a synonym pointing to a table:

-- Create the synonym 
create or replace synonym my_schema.COLORS_ALL
  for OTHER_SCHEMA.MV_CAR_COLORS;

problem is that I can query this synonym fine:

select * from my_schema.COLORS_ALL;

however, when I try to use this synonym in a Stored Proc I get an error that table or view does not exist.

what could causing this issue?? Recently the target table (MV) MV_CAR_COLORS was refreshed and indices on it were refreshed as well.

+1  A: 

You need direct grants (not through a role) on the table to the owner of the stored procedure. If by "refreshed" you mean the table was dropped and recreated, you probably didn't re-grant this direct grant as part of the refresh process.

dpbradley
`select * from dba_tab_privs where grantee in ('PUBLIC', 'my_schema') and grantor = 'OTHER_SCHEMA' and table_name = 'COLORS_ALL'` fetches a row so I am assuming that direct grants are there
learn_plsql
Interesting - what are the contents of that row?
dpbradley
The privs on the synonym don't give you privs on the MV_CAR_COLORS object. I think you'll need SELECT and REFERENCES privileges on that table
Gary
@Gary - sorry, no such thing as privileges on a synonym in Oracle. You're right about the SELECT privilege (not REFERENCES), and we'll have to see what is coming back from dba_tab_privs to make a determination. After reading the original question again, I'm wondering about the my_schema qualification in the SELECT was intentional.
dpbradley
Whoops. dpbradley is right. You can grant on a synonym, but it appears in the underlying ***_tab_privs as a grant to the object. I got confused with views which can have their own grants.
Gary