Home > ApEx > ApEx: Setting session state from within a PL/SQL Package/Procedure/Function

ApEx: Setting session state from within a PL/SQL Package/Procedure/Function

Within ApEx PL/SQL Processes, regions and items you can use the bind variable syntax (:PX_MY_ITEM) both to read and set the value of that item held in session state. Like so:

:PX_MY_ITEM := 'wibble';
l_my_local_variable := :PX_MY_ITEM;

However, in stored PL/SQL packages, procedures and functions you cannot use the bind variable syntax. Rather, you must use the v('PX_MY_ITEM') syntax. But this is read only.

So how do you set the value held in session state for a given page item from within a stored package, procedure or function?

The answer lies in the set_session_state procedure found in the APEX_UTIL package. E.g.

p_name => 'PX_MY_ITEM'
, p_value => 'wibble');

Categories: ApEx
  1. ranjan
  2. ranjan
    January 12, 2011 at 3:58 am

    This link details the step to dynamically get and set session values in oracle apex 4.0

  3. Dr Syntax
    April 21, 2009 at 3:06 pm

    you say> The answer lies in the set_sesssion_state procedure…

    i say> Too many “ssssss” in set_session_state.

    If someone uses Google, they may miss this excellent post!


  4. Andrew Tulley
    September 13, 2007 at 7:33 pm


    The best place to post questions is on the ApEx forum which can be found at:


    This exposes your question to the widest possible audience and you will almost always get a very speedy, accurate and helpful reply.


  5. Margaret Hamilton
    September 11, 2007 at 3:32 pm

    I am new with ApEx, VERY new. :o)

    I am trying to figure out how to change the value of an item (column) in the database from a PL/SQL process or javascript function. I read this article and then looked up session state. From what I understand the session state will allow the change of the value of an item but the session state is cleared regularly. How does this changed value of an item get to the database?

    “The session state process is used to modify values in the session state for applications, pages, or page items.”, I read in Easy Oracle HTML-DB, page 298. But, I’m not finding how to change the value in the database to be the same as what one might set the session state to. Help???? Thank you, M

  1. August 8, 2012 at 7:59 am
  2. June 28, 2012 at 10:54 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: