Skip to content

Instantly share code, notes, and snippets.

@casajarm
Created February 17, 2020 00:20
Show Gist options
  • Save casajarm/59312930750f1627a0f570c24a7bd2d8 to your computer and use it in GitHub Desktop.
Save casajarm/59312930750f1627a0f570c24a7bd2d8 to your computer and use it in GitHub Desktop.
Oracle Apex function that can be used to look for the latest viewed application page across a set of pages for the given app and session. Used to dynamically branch to one of these pages.
create or replace function latest_page_viewed(p_page_list in varchar2
, p_app_id in number
, p_session_id in number)
-- p_page_list is expected set of pages in colon dilimited format eg '1000:1001:10002'
return number
is
l_latest_page number;
begin
select page_id
into l_latest_page
from apex_workspace_activity_log
where application_id = p_app_id
and apex_session_id = p_session_id
and page_id IN (
select column_value
from table(apex_string.split(p_page_list,':'))
)
order by view_timestamp desc
fetch first 1 rows only;
return l_latest_page;
exception
when no_data_found then
return l_latest_page;
end latest_page_viewed;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment