Use case: During page processing, use user input on form controls rendered using the apex_item API to set session state for a page and then branch to that page. Normally, this is done using the f?p=...:10:P10_X:1 to clear cache for Page 10 and set the value for P10_X as specified. Of course, apex_application.g_fXX cannot be used in the f?p= URL so I created a process that does
followed by a branch that does a redirect to page 10.
To my surprise, P10_X was not set when page 10 was rendered. As if the clear_page_cache() was executed after the assignment to P10_X. But navigating away from the page and then back to it suddenly shows the value previously set. Or something like that, very weird. Simply changing the assignment to use
fixes the issue.
Over the years, I have been involved in Session state not set until process completes?htmldb_util.set_session_state not working with Scott Spadafore about the semantics of session state maintenance, when it is updated and such, but I am still unsure as to when, if ever, to use bind variable notation to set session state vs apex_util.set_session_state. If we can live with the fact that set_session_state does a immediate COMMIT, I don't see any benefit to using bind variable notation at all. Is that a valid conclusion to draw?
I tend to avoid assigning values to bind variables like that - but it may be due to the nature of much of my code residing in PL/SQL packages.
And due to the strange encounters I have had with this, like your linked discussions, I've tended towards using apex_util instead.
You may also enjoy this discussion