PeterP
PeterP

Reputation: 4532

How to create a "singleton" scheduled job in oracle?

It's probably just the vocabulary I am missing to find out how to do this:

A job scheduled to run regularly every 5 mins, however keeping track that there are never two instances of it running at the same time, i.e. the next instance would be postponed or skipped if the prior runs longs than 5 mins.

What is the easiest/most elegant way to achieve this?

Upvotes: 4

Views: 3214

Answers (4)

Plasmer
Plasmer

Reputation: 1130

If for some reason dbms_job or dbms_scheduler doesn't work for you, you could also use DBMS_APPLICATION_INFO.SET_APPLICATION_INFO to set the module name of your job and you could query v$session to see how many sessions are currently executing that module.

What type of job is this? A PL/SQL stored procedure?

Upvotes: -1

Erich Kitzmueller
Erich Kitzmueller

Reputation: 36987

DBMS_JOB takes care of that. Just use it.

Upvotes: 3

user123664
user123664

Reputation:

an other advantage that dbms_scheduler has above dbms_job is that you can better control the load, resource usage and that you can also run jobs external to the database.

hth, Ronald.

Upvotes: 1

DCookie
DCookie

Reputation: 43533

From the Oracle 10g administrators guide:

"The DBMS_JOB package has been superseded by the DBMS_SCHEDULER package. In particular, if you are administering jobs to manage system load, you should consider disabling DBMS_JOB by revoking the package execution privilege for users."

DBMS_SCHEDULER is Oracle's recommended way to do this now. One advantage it has is that you can manage your jobs via Enterprise Manager/Grid Control if you're using this.

Upvotes: 4

Related Questions