oracle-databaseplsqldbms-job

Use Job ID as a procedure parameter


I am using DBMS_JOB. Is it possible to pass jobId (which is an OUT parameter from the submit method) as a parameter of the calling procedure?

This is what I am trying:

jobno                 NUMBER;

sql_string:= 'BEGIN BPM_API_BATCH.' || l_procedure_name || '(:jobno, sysdate);  END;';

DBMS_JOB.SUBMIT (jobno,
                 sql_string,
                 sysdate,
                 null); 

Solution

  • Do you really need to pass the job number in as an argument?

    Within the job, you can call SYS_CONTEXT( 'USERENV', 'BG_JOB_ID' ) to get the job_id without needing to pass it in as a parameter (that will return NULL if the procedure is not called in a job.