views:

206

answers:

1

Hello, I've been trying without success to add a reference to a public synonym in a package or stored procedure in oracle for a while, and I'm wondering if there are solutions to this problem short of accessing the tables directly. For instance:

CREATE OR REPLACE PROCEDURE test_func AS
  test_int INTEGER;<br>
BEGIN<br>
  select count(*) INTO test_int FROM test_synonym;
END;
/

I know this procedure does nothing, but it is only an example. Where the table 'test_synonym' is actually a public synonym to a table in another schema. I do have select permissions to that table, but trying to compile this repeatedly gives me the error:

Error(5,38): PL/SQL: ORA-00942: table or view does not exist

Thanks for your time.

+1  A: 

Does the schema in which you're creating the procedure have direct SELECT privs (ie not via a role?)

When you create a procedure (function/package), permissions on tables need to be directly granted, not granted via a role.

cagcowboy
I talked to the DBA, and we gave the user direct selection privileges to the underlying table in the other schema, but I continue to get ORA-00942 errors.
Horus
Actually, I had done a code mod to try to get this to work before I went to the DBA, and that was causing the error, your solution (check the underlying privs, appeared to work.
Horus