How can I update my table after apex application session is expired? I want to execute the following code automatically after current session is expired.
update users set logn='N' where u_name=app_user;
commit;
Is there anyway?
Nothing actually happens when an APEX session expires. However, if the user attempts to use the session again then a check will be made to see if it has expired. So there is no event on which you can hang your update.
What you could do is have a DBMS_SCHEDULER job that runs periodically and checks for each "logged in" user whether they have any unexpired APEX sessions; if not then set them to "not logged in". Something like:
update users u
set u.logn = 'N'
where u.logn = 'Y'
and not exists (select null
from apex_workspace_sessions aws
where aws.user_name = u.u_name
and aws.session_idle_timeout_on > sysdate
);
Trying to keep track of whether APEX users are "logged in" is rather futile really - they may have closed down their laptop without "logging out" and so will show up as "logged in" until their session expires and this job runs. Probably more useful info is to know the date and time they were last active, which you can get from APEX_WORKSPACE_ACTIVITY_LOG.