API
Supported Options
Section titled “Supported Options”All supported options are inside package UC_PROGRESSBAR_PKG.
/** * Start process and set initial values. * * @p_process_name name of process to follow * @p_process_type type of process "process" of "job" * @p_maxval Max val if we have % than put 100 as 100% if you know rowcount put rowcount as maxvalue * @p_shared This parameter is used mostly for "Job" type to decide if this is global long running process (Database JOB) or displayed only in selected session (p_username, p_session) * @p_username Username, it's automated this setting is need only in case p_shared = 'N' parameter * @p_session APEX session, it's automated this setting is need only in case p_shared = 'N' parameter */ procedure start_process(p_process_name in uc_progressbar.process_name%type, p_process_type in uc_progressbar.process_type%type default 'process', p_process_text in uc_progressbar.process_text%type default null, p_maxval in uc_progressbar.max_value%type default 100, p_shared in uc_progressbar.process_shared%type default null, p_username in uc_progressbar.updated_by%type default null, p_session in uc_progressbar.updated_session%type default null ); /** * Set current status value. * * @p_process_name unique name of process * @p_value current value, if you working with percent put 10 as 10% or some current value * @p_process_text text message to display on progress bar * @p_username Username, it's automated this setting is need only in case p_shared = 'N' parameter on start_process * @p_session APEX session, it's automated this setting is need only in case p_shared = 'N' parameter on start_process */ procedure set_status(p_process_name in uc_progressbar.process_name%type, p_value in uc_progressbar.curr_value%type, p_process_text in uc_progressbar.process_text%type default null, /* Rare use case p_user and p_session only for non shared jobs */ p_username in uc_progressbar.updated_by%type default null, p_session in uc_progressbar.updated_session%type default null); /** * Check if process is still running. * * @p_process_name unique name of process * * @return true/false. */ function is_running(p_process_name in uc_progressbar.process_name%type) return boolean; /** * Stop process and set end state. * * @p_process_name unique name of process * @p_process_errorˇerror message to display * @p_username Username, it's automated this setting is need only in case p_shared = 'N' parameter on start_process * @p_session APEX session, it's automated this setting is need only in case p_shared = 'N' parameter on start_process * */ procedure error_process(p_process_name in uc_progressbar.process_name%type, p_process_error in uc_progressbar.error_text%type, /* Rare use case p_user and p_session only for non shared jobs */ p_username in uc_progressbar.updated_by%type default null, p_session in uc_progressbar.updated_session%type default null); /** * Stop process and set end state. * * @p_process_name unique name of process * @p_process_text text message to display on progress bar * @p_username Username, it's automated this setting is need only in case p_shared = 'N' parameter on start_process * @p_session APEX session, it's automated this setting is need only in case p_shared = 'N' parameter on start_process */ procedure stop_process(p_process_name in uc_progressbar.process_name%type, p_process_text in uc_progressbar.process_text%type default null, /* Rare use case p_user and p_session only for non shared jobs */ p_username in uc_progressbar.updated_by%type default null, p_session in uc_progressbar.updated_session%type default null);The plug-in uses the UC_PROGRESSBAR table (collection) this way we can also hold history if needed. Setting how long we history will be saved can be done inside package OC_PROGRESSBAR_PKG with parameter
g_history_days constant number := 30;In case we are using "Job" type processes as a long-running job, here is also an option to use dbms_application_info. Option is enabled by default with following line:
g_use_dbms_application_info constant boolean := true;You can check execution as DBA with :
select sid, sql_id, opname, target_desc, sofar, totalwork, start_time, elapsed_seconds, time_remaining, message from v$session_longops where where time_remaining > 0Examples
Section titled “Examples”Basic Sample
Section titled “Basic Sample”The following is an example of how to use the PL/SQL API inside a page process:
declare l_processname varchar2(128 char) := 'PROCESS_01';begin UC_PROGRESSBAR_PKG.start_process(p_process_name => l_processname, p_maxval => 100); for i in 1..20 loop -- Pause for 0.5 second. UC_PROGRESSBAR_PKG.set_status(p_process_name => l_processname, p_value => i*5, p_process_text => 'completed'); sys.DBMS_SESSION.sleep(0.5); end loop;
UC_PROGRESSBAR_PKG.stop_process(p_process_name => l_processname);end;Status Sample
Section titled “Status Sample”The following is an example of how to use the PL/SQL API inside a page process:
declare l_processname varchar2(128 char) := 'PROCESS_01';begin
UC_PROGRESSBAR_PKG.start_process(p_process_name => l_processname, p_maxval => 100, p_process_text => 'Starting'); for i in 1..5 loop if i = 1 then UC_PROGRESSBAR_PKG.set_status(p_process_name => l_processname, p_value => i*20, p_process_text => 'Making backup'); elsif i = 2 then UC_PROGRESSBAR_PKG.set_status(p_process_name => l_processname, p_value => i*20, p_process_text => 'Getting data'); elsif i = 3 then UC_PROGRESSBAR_PKG.set_status(p_process_name => l_processname, p_value => i*20, p_process_text => 'Processing'); elsif i = 4 then UC_PROGRESSBAR_PKG.set_status(p_process_name => l_processname, p_value => i*20, p_process_text => 'Finishing'); elsif i = 5 then UC_PROGRESSBAR_PKG.set_status(p_process_name => l_processname, p_value => i*20, p_process_text => 'Clean up'); sys.DBMS_SESSION.sleep(2); end if; end loop;
UC_PROGRESSBAR_PKG.stop_process(p_process_name => l_processname);end;