---
title: "查看oracle创建的任务计划的job "
author: "foolraty"
date: "2011-06-28T15:45:23Z"
tags: []
categories: ["数据库"]
slug: "oracle-job"
draft: false
lastmod: "2011-06-28T15:45:23Z"
id: 1107803
url: "https://foolraty.iteye.com/blog/1107803"
---

How to find the job name if a scheduled job fails with ORA-12012

When a scheduled job fails, the alert log shows an error message like:  
"ORA-12012 error on auto execute of job 47544".

How do I correlate the job number value in the alert log to the job name  
listed in dba\_scheduler\_jobs?

Solution  
The usage of finding out job information for Scheduler Jobs is different than the usage of the old Job mechanism.

In both cases ( DBMS\_SCHEDULER and DBMS\_JOB) the alert.log will show you an error when the job failed.

Example:  
Errors in file d:\\oracle\\product\\10.2.0\\admin\\orcl\\bdump\\orcl\_j000\_3036.trc:  
ORA-12012: error on auto execute of job 54887  
ORA-06550: line ORA-06550: line 1, column 417:  
PL/SQL: ORA-00942: table or view does not exist  
ORA-06550: line 1, column 405:  
PL/SQL: [**SQL**]() Statement ignored  
, column :

where the number in the error message is the job identifier.

For DBMS\_JOB usage:  
To find out more information about that failing job you can simply go over the jobnumber and select the needed information from the view dba\_jobs.

SQL&gt;select job, what from dba\_jobs ;  
JOB WHAT  
\---------- ----------------------------------------------------------  
1 EMD\_MAINTENANCE.EXECUTE\_EM\_DBMS\_JOB\_PROCS();  
21 BEGIN MGMT\_BSLN.COMPUTE\_ALL\_STATISTICS;/\*DB\*/END;  
22 BEGIN MGMT\_BSLN.SET\_ALL\_THRESHOLDS;/\*DB\*/END;  
Note: The job does not have a job\_name when dbms\_job is used.

 

For DBMS\_SCHEDULER usage:  
For the application user the usage of scheduled jobs is now more defined by the name of the job and not by the job identifier.  
Unfortunal the error message ORA-12012 will not show you the name of the job, but will still show you the job identifier.  
This job identifier is now more dictionary information and correlates to the object\_id from the view dba\_objects

The job identifier is stored in the table sys.scheduler$\_job under column obj#.

When a relation for the job identifier to the job name is needed then the following select statement can help:

 

select obj# , object\_name from sys.scheduler$\_job , dba\_objects  
where obj# = object\_id;

 

Example:

SQL&gt; select obj# , object\_name from sys.scheduler$\_job , dba\_objects  
2 where obj# = object\_id;

OBJ# OBJECT\_NAME  
\---------- ----------------------------  
54888 RUNTEST\_JOB  
54869 RUNTEST\_JOB

Having the name of the job you can select the relevant scheduler views like DBA\_SCHEDULER\_JOB\_RUN\_DETAILS  
to find out more infomation like the status , or the additional information for the scheduled job.

As an alternative, the generated job trace file can be viewed to find out the related job name:

Example:  
orcl\_j000\_3036.trc:  
\------------------------  
....  
\*\** ACTION NAME:(RUNTEST\_JOB) 2008-10-21 09:14:30.165  
\*\** MODULE NAME:(DBMS\_SCHEDULER) 2008-10-21 09:14:30.165  
\*\** SERVICE NAME:(SYS$USERS) 2008-10-21 09:14:30.165  
\*\** SESSION ID:(145.37) 2008-10-21 09:14:30.165  
\*\** 2008-10-21 09:14:30.165  
ORA-12012: error on auto execute of job 54887  
ORA-06550: line ORA-06550: line 1, column 417:  
PL/SQL: ORA-00942: table or view does not exist  
ORA-06550: line 1, column 405:  
PL/SQL: SQL Statement ignored  
, column :  
where the ACTION NAME is the name of the job.