25.2.6.8.2 Inserting Account Creation Request

Insert an account creation request for a background job to process outside the workflow session.

To create an APEX user, you call the CREATE_USER procedure in the APEX_UTIL package. However, since this must be run from context outside of an APEX application session, the CREATE_USER function in the Woods Clinic package uses a two-step approach. Here, it simply inserts a row in a table to track the request to create a new user account. Then, a DBMS_SCHEDULER background job periodically processes the table to actually create the accounts.

-- package frc_apex_user
procedure create_user(
    p_username   in varchar2, 
    p_email      in varchar2,
    p_patient_id in number)
is
    l_group_id number := apex_util.get_group_id(p_group_name=>'Patients');
begin                          
    insert into frc_apex_users_queue(
       username,
       group_id,
       email,
       patient_id)
    values (
       upper(p_username),
       l_group_id,
       p_email,
       p_patient_id);
end;