Obtain the session ID of the job.
Reference Original:
How to get the session ID of the running job (Doc ID 1604966.1)
Applicable:
Oracle Database-Enterprise Edition-version 9.2.0.8 and later
Information in this document applies to any platform.
Objectives:
How can I obtain the session ID of a job running?
---> Note: The jobs mentioned in this article include those created by dbms_job and DBMS_Scheduler.
Solution:
If a job is created using dbms_job package, use the following statement:
Set feedback off
Alter session set nls_date_format = 'dd-MON-YYYY hh24: MI: ss ';
Set feedback on
Select Jr. Job, S. username, S. Sid, S. Serial #, P. spid, S. lockwait, S. logon_time
From dba_jobs_running Jr, V $ session S, V $ PROCESS p
Where Jr. Sid = S. Sid
And S. paddr = P. ADDR
Order by Jr. job;
If the job is created using DBMS_Scheduler, use the following statement:
Set feedback off
Alter session set nls_date_format = 'dd-MON-YYYY hh24: MI: ss ';
Set feedback on
Select RJ. job_name, S. username, S. Sid, S. Serial #, P. spid, S. lockwait, S. logon_time
From dba_scheduler_running_jobs RJ, V $ session S, V $ PROCESS p
Where RJ. session_id = S. Sid
And S. paddr = P. ADDR
Order by RJ. job_name;