why dbms_job.submit doesn't work while the same code work with execute immediate?

送分小仙女□ 提交于 2019-12-25 04:51:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!