oracle-databaseoracle12cdbms-job

Oracle12: calling a procedure inside a Package


I have a DBMS_JOB job declares as follows

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'GET_ENAGAS_INVOICES_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN LOPES.GET_ENAGAS_INVOICES; END;',
repeat_interval =>'FREQ=MINUTELY; INTERVAL=5; BYHOUR=9,22; BYDAY=TUE,WED,THU,FRI,SAT,SUN', 
enabled => TRUE,
comments => 'GET_ENAGAS_INVOICES');
END;
/

I moved this procedure inside a package and I want to know if it is still possible to run the job


Solution

  • Yes, just use SCHEMA_NAME.PACKAGE_NAME.PROCEDURE_NAME:

    BEGIN
      DBMS_SCHEDULER.CREATE_JOB (
        job_name => 'GET_ENAGAS_INVOICES_JOB',
        job_type => 'PLSQL_BLOCK',
        job_action => 'BEGIN LOPES.PACKAGE_NAME.GET_ENAGAS_INVOICES; END;',
        repeat_interval =>'FREQ=MINUTELY; INTERVAL=5; BYHOUR=9,22; BYDAY=TUE,WED,THU,FRI,SAT,SUN', 
        enabled => TRUE,
        comments => 'GET_ENAGAS_INVOICES'
      );
    END;
    /