Saturday, November 15, 2008

Trace an Oracle Scheduler Job

Got a request to trace a scheduler job. I did the following:

1. Find the pl/sql block this job is doing:

select JOB_ACTION from dba_scheduler_jobs where job_name='XXXX_MOBLAL01ANK_CORR_JOB';

JOB_ACTION
----------------------------------------------------------------------------------
BEGIN XXXX_CORRELATION('MOBLAL01ANK', 10000, 60); END;


2. Disable this job after it is stopped. (login as job owner)

begin
dbms_scheduler.disable(user||'.XXXX_MOBLAL01ANK_CORR_JOB');
end;
/


3. Trace a sql session:

alter session set tracefile_identifier ='XXXX';
alter session set timed_statistics=true;
alter session set events '10046 trace name context forever, level 12';

BEGIN
XXXX_CORRELATION('MOBLAL01ANK', 10000, 60);
END;
/
exit;


4. Enable this job after trace is done

begin
dbms_scheduler.enable(user||'.XXXX_MOBLAL01ANK_CORR_JOB');
end;
/

5. Issue the following query to check the job state:
select state from dba_scheduler_jobs where job_name='XXXX_MOBLAL01ANK_CORR_JOB';

STATE
---------------
SCHEDULED

No comments: