Oracle用参数调用作业 [英] Oracle Calling a job with arguments

查看:106
本文介绍了Oracle用参数调用作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程parse_data,它带有3个全为NUMBER的参数.我创建了一个带有三个参数的程序,然后创建了一个将运行存储过程的作业.代码如下:

I have a stored procedure parse_data which takes 3 arguments which are all NUMBER. I have created a program with three arguments and then a job that will run the stored procedure. The code looks like this:

BEGIN
  dbms_scheduler.create_program(program_name        => 'PARSE_PROGRAM',
                          program_type        => 'STORED_PROCEDURE',                                                          
                          program_action      => 'parse_data', 
                          number_of_arguments => 3,
                          enabled             => false,
                          comments            => '');

  dbms_scheduler.define_program_argument(program_name      => 'PARSE_PROGRAM',
                                   argument_name     => 'file_id',
                                   argument_position => 1,
                                   argument_type     => 'NUMBER',
                                   default_value     => '');

  dbms_scheduler.define_program_argument(program_name      => 'PARSE_PROGRAM',
                                   argument_name     => 'file_upload_id',
                                   argument_position => 2,
                                   argument_type     => 'NUMBER',
                                   default_value     => '');    

  dbms_scheduler.define_program_argument(program_name      => 'PARSE_PROGRAM',
                                   argument_name     => 'type_id',
                                   argument_position => 3,
                                   argument_type     => 'NUMBER',
                                   default_value     => '');                                       

  dbms_scheduler.enable (name => 'PARSE_PROGRAM');

  dbms_scheduler.create_job(job_name        => 'parse_job',
                          program_name    => 'PARSE_PROGRAM',
                          start_date      => systimestamp);

 END;

我的问题是,现在已经运行了该sql,并且程序和作业现在已在dbms中,我该如何实际调用运行作业并传入3个参数?

My question is now that this sql has been run and the program and job are now in the dbms, how do I actually make the call to run the job and pass in the 3 arguments?

推荐答案

您应该首先创建作业,然后定义参数,然后运行它.创建它时,请将启用的属性设置为false,这样它就不会运行:

You should first create the job, then define the arguments, and then run it. When you create it, set the enabled atribute to false, so it won't run yet:

dbms_scheduler.create_job(job_name        => 'parse_job',
                          program_name    => 'PARSE_PROGRAM',
                          start_date      => systimestamp,
                          enabled         => false );

然后将参数传递给作业:

Then pass the arguments to the job:

dbms_scheduler.set_job_argument_value(job_name => 'parse_job',
                                      argument_position => 1,
                                      argument_value => 1);

然后通过呼叫启用它:

dbms_scheduler.enable('parse_job');

这篇关于Oracle用参数调用作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆