Answer
For this kind of error on a custom ad-hoc PL/SQL block, check two things specifically: read access on the underlying view your query selects from, and execute access on any API package function you're calling directly — both need to be explicitly granted to whatever role/user context the block runs under (they're not implied just because you can see the object in the data dictionary). Granting SELECT on the view and EXECUTE on the package is the standard fix for this exact class of privilege error.