PL/SQL doesnt return rows
Many times, when the code is not correctly working iinside package/procedure and is ok in anonymous PL/SQL; it comes from the AUTHID clause restrictions: 

http://psoug.org/definition/AUTHID.htm