I have a routine whose task is to extract code from ALL_SOURCE. This is done using the following cursor:
    CURSOR w_cur ( p_name VARCHAR2 , p_type VARCHAR2) IS
                   SELECT text , line
                     FROM ALL_SOURCE
                    WHERE UPPER(TYPE)  = UPPER(p_type)
                      AND UPPER(NAME)  = UPPER(p_name)
                      AND UPPER(OWNER) = UPPER(NVL(G_Owner_to_User,USER))
                    ORDER BY line
                    ;
I'm executing this routine from a user with DBA and SYS privileges. When attempting to extract the "BODY" of a "PACKAGE", if the package belongs to the same user running the program, I get the correct result. If, on the other hand, I attempt to extract the "BODY" of a package that belongs to another user, I get an empty result.
The interesting thing is that, when running the above "SELECT" from within SQL DEVELOPER (same user) I do get the expected code.
This looks like a "PRIVILEGE" related thing, but I have no idea why I'm getting different results and which privilege is missing.
Thanks for your comments.
Fernando.
                        
Create the procedure with
AUTHID CURRENT_USERand Oracle will use the invoker's roles to determine access privileges. The default isAUTHID DEFINER, which does not include privileges granted through a role (except for special roles like PUBLIC).These functions show the difference between invoker's and definer's rights with
ALL_SOURCE.Results: