DBMS_SCHEDULER package to send your APEX_AUTOMATION.EXECUTE to the background.
APEX_AUTOMATION.EXECUTE :- the APEX_AUTOMATION.EXECUTE procedure executes the automation in the foreground (so you have to wait),
DBMS_SCHEDULER.CREATE_JOB :-executes the automation in the background.
Objective:- DBMS_SCHEDULER package to send your APEX_AUTOMATION.EXECUTE to the background.
declare
l_filters apex_exec.t_filters;
l_static_id apex_appl_automations.static_id%type; l_exists number; l_application_id apex_appl_automations.application_id%type; l_job_short_name scheduled_jobs.job_short_name%type; BEGIN begin select static_id,application_id into l_static_id ,l_application_id from apex_appl_automations where AUTOMATION_ID=:P10_STATIC_ID; end; l_job_short_name:=replace(l_static_id,'-','_'); /* apex_exec.add_filter( p_filters => l_filters, p_column_name => 'DEPTNO', p_filter_type => apex_exec.c_filter_eq, p_value => 10 ); apex_automation.execute( p_static_id => l_static_id, p_filters => l_filters );*/ select count(*) into l_exists from user_scheduler_jobs where job_name = l_job_short_name; if l_exists > 0 then dbms_scheduler.run_job (l_job_short_name,false); else DBMS_SCHEDULER.CREATE_JOB ( job_name => l_job_short_name, job_type => 'PLSQL_BLOCK', job_action => apex_string.join( apex_t_varchar2( 'begin', ' apex_session.create_session(' || :APP_ID || ',' || :APP_PAGE_ID || ',''' || replace( :APP_USER, '''', '''''' ) || ''');', ' apex_automation.execute(' || :APP_ID || ',''' || replace( l_static_id, '''', '''''' ) || ''');', 'end;' ) ), start_date => sysdate, repeat_interval => null, enabled => true ); end if; END;
Comments
Post a Comment