Home > Database > Mysql Tutorial > body text

ORACLE—005:创建JOB(二)

WBOY
Release: 2016-06-07 15:02:31
Original
1181 people have browsed it

如果需要创建带参数的job,如何创建呢。 我们直接将参数声明,并赋值,然后传给job调用的存储过程即可。 例如,存储过程名为Pro_Test_JOB,参数共有一个,是VARCHAR2类型。 创建JOB如下: declare job number; v_count number;begin SELECT COUNT(*) INTO v_

如果需要创建带参数的job,如何创建呢。

我们直接将参数声明,并赋值,然后传给job调用的存储过程即可。

例如,存储过程名为Pro_Test_JOB,参数共有一个,是VARCHAR2类型。

创建JOB如下:

declare
  job number;
  v_count number;
begin 
    SELECT COUNT(*)
    INTO v_count
    FROM user_jobs uj
    WHERE  upper(uj.what) = 
    UPPER('declare para_data VARCHAR2(100):=''参数'';begin  Pro_Test_JOB(para_data); end;');
    
    if v_count = 0 then
      sys.dbms_job.submit(job => job, 
                      what => 
                      'declare para_data VARCHAR2(100):=''参数'';begin  Pro_Test_JOB(para_data); end;', 
                      next_date =>sysdate , 
                      interval => 'sysdate+2/24');
    dbms_job.run(job);
    commit;
  end if;
end;
Copy after login


 

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!