In this post I will provide a sample simple code to submit a dbms_scheduler job.
- Create a procedure. You can create a procedure inside a package also if needed.
--create tableCREATE TABLExxaj_debug ( ,idNUMBER,msgVARCHAR2(4000) ,call_stackVARCHAR2(4000) ,date_stampDATE);--create sequenceCREATE SEQUENCExxaj_seqSTART WITH1INCREMENT BY1;--create procedureCREATE OR REPLACE PROCEDURExxaj_proc (msgVARCHAR2)ISPRAGMA autonomous_transaction; BEGIN INSERT INTOxxaj_debugVALUES( xxaj_seq.NEXTVAL,msg ,dbms_utility.format_call_stack ,SYSDATE);COMMIT;ENDxxaj_proc;
Parameters
job_name : you can give any name. Give something meaningful so that you can filter with
the name when trouble shooting
job_type : in this case it is a stored procedure
job_action : in this case we are executing a stored procedure, so specify the procedure name
enabled : we want the job to run straight away, so set to true
BEGINdbms_scheduler.create_job (job_name =>'XXAJ_JOB_'||TO_CHAR(SYSDATE,'DDMMHH24MI') ,job_type =>'STORED_PROCEDURE',job_action =>'xxaj_proc',enabled =>TRUE);END;
There are lot more options on the job submission. I will create a separate blog with different variances.
You can also refer the below oracle site for the details.
Refer:Scheduler (DBMS_SCHEDULER) in Oracle Database 10g Onward
Feel free to point out if anything is missing/wrong in this blog.
No comments:
Post a Comment