Roles are never enabled during the execution of a procedure except in the special case of Invokers Rights which is a new feature in Oracle8i, release 8.1.
This fact is documented application developers guide:
To create a stand-alone procedure or function, or package specification or body, you must meet the following prerequisites:
You must have the CREATE PROCEDURE system privilege to create a procedure or package in your schema, or the CREATE ANY PROCEDURE system privilege to create a procedure or package in
another user's schema.
Attention: To create without errors, that is, to compile the procedure or package successfully, requires the following additional privileges: The owner of the procedure or package must have been explicitly granted the necessary object privileges for all objects referenced within the body of the code; the owner cannot have obtained required privileges through roles.
scott@10GR2> drop table t purge;
Table dropped.
scott@10GR2> create table t(x number);
Table created.
scott@10GR2> create role r1;
Role created.
scott@10GR2> grant select on t to r1;
Grant succeeded.
scott@10GR2> grant r1 to hr;
Grant succeeded.
scott@10GR2> connect hr/hr
Connected.
hr@10GR2> create synonym t for scott.t;
Synonym created.
hr@10GR2> create or replace procedure p1 as
2 l_val scott.t%rowtype;
3 begin
4 dbms_output.put_line (' procedure p1 invoked ');
5 end;
6 /
Warning: Procedure created with compilation errors.
hr@10GR2> show err;
Errors for PROCEDURE P1:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/8 PL/SQL: Item ignored
2/8 PLS-00201: identifier 'SCOTT.T' must be declared
hr@10GR2> create or replace procedure p2 as
2 l_val t%rowtype;
3 begin
4 dbms_output.put_line (' procedure p1 invoked ');
5 end;
6 /
Warning: Procedure created with compilation errors.
hr@10GR2> show err;
Errors for PROCEDURE P2:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/8 PL/SQL: Item ignored
2/8 PLS-00201: identifier 'T' must be declared
As stated from Product documentation, this can be solved by granting necessary privileges to owner rather that through Roles.
hr@10GR2> connect scott/tiger
Connected.
scott@10GR2> grant select on t to hr;
Grant succeeded.
scott@10GR2> connect hr/hr
Connected.
hr@10GR2> alter procedure p1 compile;
Procedure altered.
hr@10GR2> alter procedure p2 compile;
Procedure altered.