Why doesn’t PL/SQL respect privileges granted by Roles?

I think you may be fighting over Invokers rights vs Definers rights.

From Oracle docs:

During a server call, when a DR unit is pushed onto the call stack,
the database stores the currently enabled roles and the current values
of CURRENT_USER and CURRENT_SCHEMA. It then changes both CURRENT_USER
and CURRENT_SCHEMA to the owner of the DR unit, and enables only the
role PUBLIC
. (The stored and new roles and values are not necessarily
different.) When the DR unit is popped from the call stack, the
database restores the stored roles and values. In contrast, when an IR
unit is pushed onto, or popped from, the call stack, the values of
CURRENT_USER and CURRENT_SCHEMA, and the currently enabled roles do
not change

So if you want Oracle to “respect the privileges granted by roles”, then perhaps you want to use Invokers rights ( AUTHID CURRENT_USER clause)

Leave a Comment