Skip to content

Latest commit

 

History

History
332 lines (217 loc) · 6.22 KB

oos_util_apex.md

File metadata and controls

332 lines (217 loc) · 6.22 KB

OOS_UTIL_APEX

IS_DEVELOPER Function

Returns true/false if APEX developer is enable
Supports both APEX 4 and 5

Can be used in APEX to declaratively determine if in development mode.

Syntax

function is_developer
  return boolean

Parameters

Name Description
return boolan True: Developer has an active session in Application Builder

Example

begin
  if oos_util_apex.is_developer then
    dbms_output.put_line('Developer mode');
  else
    dbms_output.put_line('Non-Dev mode');
  end if;
end;

IS_DEVELOPER_YN Function

Returns Y/N if APEX developer is enable
See is_developer for details

Syntax

function is_developer_yn
  return varchar2

Parameters

Name Description
return Y or N

Example

begin
  if oos_util_apex.is_developer_yn = 'Y' then
    dbms_output.put_line('Developer mode');
  else
    dbms_output.put_line('Non-Dev mode');
  end if;
end;

IS_SESSION_VALID Function

Checks if APEX session is still active/valid

Syntax

function is_session_valid(
  p_session_id in apex_workspace_sessions.apex_session_id%type)
  return boolean

Parameters

Name Description
p_session_id APEX session ID
return true/false

Example


begin
  if oos_util_apex.is_session_valid(p_session_id => :app_session) then
    dbms_output.put_line('Session is active');
  else
    dbms_output.put_line('Session is inactive');
  end if;
end;

IS_SESSION_VALID_YN Function

Checks if session is still active

Syntax

function is_session_valid_yn(
  p_session_id in apex_workspace_sessions.apex_session_id%type)
  return varchar2

Parameters

Name Description
p_session_id APEX session ID
return Y/N

Example


begin
  if oos_util_apex.is_session_valid_yn(p_session_id => :app_session) = 'Y' then
    dbms_output.put_line('Session is active');
  else
    dbms_output.put_line('Session is inactive');
  end if;
end;

CREATE_SESSION Procedure

Creates a new APEX session.
Useful when testing APEX functionality in PL/SQL or using apex_mail etc

Can only create one per Oracle session. To connect to a different APEX session, reconnect the Oracle session

Notes:

Syntax

procedure create_session(
  p_app_id in apex_applications.application_id%type,
  p_user_name in apex_workspace_sessions.user_name%type,
  p_page_id in apex_application_pages.page_id%type default null,
  p_session_id in apex_workspace_sessions.apex_session_id%type default null)

Parameters

Name Description
p_app_id
p_user_name
p_page_id Page to try and register for post login. Recommended to leave null
p_session_id Session to re-join. Recommended leave null

Example


begin
  oos_util_apex.create_session(
    p_app_id => :app_id,
    p_user_name => :app_user,
    p_page_id => :app_page_id);
  );
end;

JOIN_SESSION Procedure

Join an existing APEX session

Notes:

  • v('P1_X') won't work. Use apex_util.get_session_state('P1_X') instead

Syntax

procedure join_session(
  p_session_id in apex_workspace_sessions.apex_session_id%type,
  p_app_id in apex_applications.application_id%type default null)

Parameters

Name Description
p_session_id The session you want to join. Must be an existing active session.
p_app_id Use if multiple applications are linked to the same session. If null, last used application will be used.

Example


begin
  oos_util_apex.join_session(
    p_session_id => :app_session,
    p_app_id => :app_id
  );
end;

TRIM_PAGE_ITEMS Procedure

Trims whitespace APEX page items (before and after).
Useful when submitting a page to trim all items.

Notes:

  • Suggested to run submit page process application wide
  • Excludes inputs that users shouldn't modify and password fields
    • Ex: select list, hidden values, files

Syntax

procedure trim_page_items(
  p_page_id in apex_application_pages.page_id%type default apex_application.g_flow_step_id)

Parameters

Name Description
p_page_id Items on this page will be trimmed.

Example


begin
  oos_util_apex.trim_page_items(p_page_id => :app_page_id);
end;

IS_PAGE_ITEM_RENDERED Function

Returns true/false if page item was rendered

Notes:

  • This should only run on a page submit process otherwise it won't work. An error is raised otherwise

Syntax

function is_page_item_rendered(
  p_item_name in apex_application_page_items.item_name%type)
  return boolean

Parameters

Name Description
return true/false

Example

begin
  if oos_util_apex.is_page_item_rendered(p_item_name => 'P1_EMPNO') then
    dbms_output.put_line('P1_EMPNO rendered');
  else
    dbms_output.put_line('P1_EMPNO was not rendered');
  end if;
end;