Instead of using using sys.dbms_shared_pool.purge, which requires extra privileges, would it be easier to always use a flashback query to force hard parsing? Similar to the solution used here: https://stewashton.wordpress.com/2021/11/09/sql-table-macros-5-dynamic-but-dangerous/
The downside is that flashback also requires:
EXECUTE on DBMS_FLASHBACK
FLASHBACK on all the tables accessed by the query.