建一个作业,每天晚上执行一个存储过程

1、建一个作业,每天晚上执行一个存储过程
(A)
begin
  sys.dbms_job.submit(job => :job,
                      what => 'DECLARE X VARCHAR2(30);
I DATE;
BEGIN
I:=SYSDATE;
X:=TO_CHAR(I,''YYYY/MM/DD'');
PROC_INV_AGING_BALANCES_CT(X);
END;',
                      next_date => to_date('10-05-2007 15:29:17', 'dd-mm-yyyy hh24:mi:ss'),
                      interval => 'SYSDATE+1/72');
  commit;
end;
(B)
CREATE OR REPLACE PROCEDURE TmpInt AS
  v_name varchar2(10);
  v_empno number(4);
BEGIN
  v_name := 'exam';
  SELECT max(empno)+1 into v_empno from emp;
  INSERT INTO emp(empno,ename)
  VALUES(v_empno,v_name);
EXCEPTION
  WHEN OTHERS THEN
    NULL;
  COMMIT;
END TmpInt;
/

VARIABLE v_JobNum number
BEGIN
  DBMS_JOB.SUBMIT(:v_JobNum,
                        'TmpInt;',
                        SYSDATE,
                        'SYSDATE + (60 / (24*60*60))'
);
END;
/
SQL/PLUS下运行通过
 

你可能感兴趣的:(Date,exception,null,存储,insert,作业)