sql - How to stop running jobs simultaneously in Oracle -


i have written procedure , in creating 1 job. , want once 1st job gets completed should create 2nd job. when running code creating both jobs simultaneously , running both jobs @ same time. kindly find code

create or replace procedure test_proc  v_count number; v_text varchar2(15); v_date varchar2(15); v_date2 date; v_status varchar2(15);  begin  execute immediate 'truncate table dataq_support.test_vishal'; select count(*) v_count dataq_support.test_proc_table; select max(fdate) v_date dataq_support.test_proc_table;  select distinct fpermissions v_text dataq_support.test_proc_table;  select to_date (substr(v_date,1,6),'mm-dd') v_date2 dual;   insert dataq_support.test_vishal(id,text) values (1,v_date2); commit;  if v_date2 = to_date('08-sep-17','dd-mm-yy')  insert dataq_support.test_vishal(id,text) values (1,'1st if'); commit; if v_count = 266  insert dataq_support.test_vishal(id,text) values (2,'2st if'); commit; if v_text = '-rwxrwxrwx' insert dataq_support.test_vishal(id,text) values (3,'3st if'); commit;  dbms_scheduler.create_job( job_name => 'first_job', job_type => 'plsql_block', job_action =>    '   begin   impdata.gen_imp.read_and_import_tables(''sap_without_bom'');   end;',  start_date => systimestamp,  enabled => true,  comments => 'import job');    else insert dataq_support.test_vishal(id,text) values (3,'else'); commit; end if; end if; else     insert dataq_support.test_vishal(id,text) values (4,'else'); commit; end if;  insert dataq_support.test_vishal(id,text) values (5,'ending'); commit;  dbms_scheduler.create_job(  job_name => 'second_job',  job_type => 'plsql_block',  job_action => '   begin      import_refdev_analyse;    end;',   start_date => systimestamp,    comments => 'rerun daily import , analyze job',    enabled => true );  exception when others  dbms_output.put_line('there issue');   end;` 

here have created 1st job first_job. want once first_job gets completed should create job namely second_job.

use_current_session argument of run_job determines whether job runs synchronously or asynchronously

the following example synchronously runs 2 jobs:

begin   dbms_scheduler.run_job(     job_name            => 'dss.etljob1, dss.etljob2',     use_current_session => true); end; / 

this way 2 jobs dss.etljob1, dss.etljob2 executed sequentially 1 after (just wanted).


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -