我写了一个程序,因为我创造了一份工作。我希望,一旦第一份工作完成,那么它应该创建第二份工作。但是当我运行我的代码时,它同时创建两个作业并同时运行这两个作业。请找到代码
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(*) into v_count from DATAQ_SUPPORT.test_proc_table;
select max(fdate) into v_date from DATAQ_SUPPORT.test_proc_table;
select distinct fpermissions into v_text from DATAQ_SUPPORT.test_proc_table;
select to_date (SUBSTR(v_date,1,6),'MM-DD') into v_date2 from dual;
insert into dataq_support.test_vishal(id,text) values (1,v_date2);
commit;
if v_date2 = to_date('08-SEP-17','DD-MM-YY')
then
insert into dataq_support.test_vishal(id,text) values (1,'1st if');
commit;
if v_count = 266
then
insert into dataq_support.test_vishal(id,text) values (2,'2st if');
commit;
if v_text = '-rwxrwxrwx'
then
insert into 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 into dataq_support.test_vishal(id,text) values (3,'else');
commit;
end if;
end if;
else
insert into dataq_support.test_vishal(id,text) values (4,'Else');
commit;
end if;
insert into 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 and Analyze Job',
enabled => TRUE
);
EXCEPTION when others
then
dbms_output.put_line('There is some issue');
end;`
我在这里创建了FIRST_JOB的第一份工作。我希望一旦FIRST_JOB完成,那么它应该创建另一个工作,即SECOND_JOB。
答案 0 :(得分:2)
<!-- ** PROJECTS : LEFT ** -->
<div class="lines title">
<div class="line proj line-proj1"></div>
<div class="line proj line-proj2"></div>
<div class="line proj line-proj3"></div>
<div class="line proj line-proj4"></div>
<div class="line proj line-proj5"></div>
<div class="line proj line-proj6"></div>
<div class="line proj line-proj7"></div>
<div class="line proj line-proj8"></div>
</div>
参数确定作业是同步还是异步运行
以下示例同步运行两个作业:
//Setting clickListener on earlierEnrollmentRadioButton
earlierEnrolmentRB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
earlierRadioButtonChecked();
}
});
//Setting clickListener on laterEnrollmentRadioButton
laterEnrolmentRB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
laterRadioButtonChecked();
}
});
//Initialization of list of courses for Spinner
final String[] courseArray = new String[4];
{
courseArray[0] = getString(R.string.undergraduate_man);
courseArray[1] = getString(R.string.undergraduate_traf);
courseArray[2] = getString(R.string.undergraduate_admin);
courseArray[3] = getString(R.string.graduate_man);
}
//Creating ArrayAdapter of list of courses
final ArrayAdapter courseAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item, courseArray);
//Setting list type
courseAdapter.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
//Setting adapter to courses Spinner
courses.setAdapter(courseAdapter);
//Creating listener for selecting specific item from @courseArray
courses.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
//Getting item from Spinner
cors = parent.getItemAtPosition(pos).toString();
if (cors.equals(courseArray[0])) {
laterRadioButtonChecked();
fullScholar = 6000.0;
} else if (cors.equals(courseArray[1])) {
laterRadioButtonChecked();
fullScholar = 7500.0;
} else if (cors.equals(courseArray[2])) {
laterRadioButtonChecked();
fullScholar = 6000.0;
} else if (cors.equals(courseArray[3])) {
laterRadioButtonChecked();
fullScholar = 6000.0;
} else {
//Do nothing
}
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
});
}
//This method calls values of enrollment before 2014/2015
public void earlierRadioButtonChecked() {
if(cors.equals(getString(R.string.undergraduate_traf))) {
ectsPriceText.setText("150.00 kn");
price = 150;
} else {
ectsPriceText.setText("100.00 kn");
price = 100;
}
}
//This method calls values of enrollment after 2014/2015
public void laterRadioButtonChecked() {
if(cors.equals(getString(R.string.undergraduate_traf))) {
ectsPriceText.setText("250.00 kn");
price = 250;
} else {
ectsPriceText.setText("200.00 kn");
price = 200;
}
}
这样,2个作业use_current_session
一个接一个地顺序执行(就像你想要的那样)。