问题
This is the frist time that I am going to use dbms_job.submit.
The following piece of code doesn't work:
declare
i_job_no BINARY_INTEGER;
begin
dbms_job.submit(JOB => i_job_no, what => 'declare x number; begin x := f_threads(''my_program'', '|| 6058883 ||' , '|| 2 || '); end;', next_date => sysdate);
dbms_output.put_line(i_job_no);
end;
but the same thing works fine with execute immediate. Can anyone help?!
> declare
i_job_no BINARY_INTEGER;
begin
execute immediate 'declare x number; begin x := f_threads(''my_program'', '|| 6058883 ||' , '|| 2 || '); end;';
end;
thanks!
回答1:
in this way your pl/sql block will work:
declare
i_job_no BINARY_INTEGER;
begin
dbms_job.submit(JOB => i_job_no, what => 'declare x number; begin x := f_threads(''my_program'', '|| 6058883 ||' , '|| 2 || '); end;', next_date => sysdate);
dbms_output.put_line(i_job_no);
commit;
end;
You are missing a commit
in you code
Regards Giova
回答2:
try this:
declare
i_job_no BINARY_INTEGER;
begin
dbms_job.submit(JOB => i_job_no, what => 'declare x number; begin x := f_threads(''my_program'', '|| 6058883 ||' , '|| 2 || '); end;', next_date => sysdate);
dbms_output.put_line(i_job_no);
commit;
dbms_job.run(i_job_no);
end;
来源:https://stackoverflow.com/questions/34808397/why-dbms-job-submit-doesnt-work-while-the-same-code-work-with-execute-immediate