Overcoming PL/SQL to PL/pgSQL conversion challenges