Showing posts with label DBMS_SCHEDULER. Show all posts
Showing posts with label DBMS_SCHEDULER. Show all posts

Tuesday, August 12, 2014

ORA-27476: "SYS.MY_FANCY_JOB_CLASS" does not exist

Always check out the original article at http://www.oraclequirks.com for latest comments, fixes and updates.

Ever exported a whole schema containing DBMS_SCHEDULER jobs with non-default job classes?
Chances are that you hit the following error message when you attempt to import the dump later on.
 
ORA-39083: Object type PROCOBJ failed to create with error:
ORA-27476: "SYS.MY_FANCY_JOB_CLASS" does not exist

Job classes defined with DBMS_SCHEDULER.CREATE_JOB_CLASS are not owned by the schema user but by user SYS (as inferred by looking at the error message itself).

As a result, any jobs whose job class has not been re-created before importing the dump, won't be (re)created.



If, for some reason, the script for creating the job is not readily available but you have access to the database where the dump was taken, you can quickly generate a script for the job via the "Create like" feature of SQLDeveloper.
Note however that the missing job class must be (re)created manually, SQLDeveloper doesn't help with that.

exec DBMS_SCHEDULER.CREATE_JOB_CLASS('MY_FANCY_JOB_CLASS');

See message translations for ORA-27476 and search additional resources.

Friday, August 03, 2012

ORA-27486: insufficient privileges.

Always check out the original article at http://www.oraclequirks.com for latest comments, fixes and updates.

A short account of a couple of occurrences of ORA-27486.

exec  dbms_scheduler.create_job_class('TEST_CLASS');

Error starting at line 1 in command:
exec  dbms_scheduler.create_job_class('TEST_CLASS')
Error report:
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 242
ORA-06512: at "SYS.DBMS_SCHEDULER", line 706
ORA-06512: at line 1
27486. 00000 -  "insufficient privileges"
*Cause:    An attempt was made to perform a scheduler operation without the
           required privileges.
*Action:   Ask a sufficiently privileged user to perform the requested
           operation, or grant the required privileges to the proper user(s).

The user performing this operation needs the MANAGE SCHEDULER privilege.
Please note that having the CREATE JOB privilege is not enough.

That was easy.

connect system 
exec  dbms_scheduler.create_job_class('TEST_CLASS');
 
connect test
 
begin
  dbms_scheduler.create_job(
   job_name          =>  'TEST_JOB',
   job_type          =>  'PLSQL_BLOCK',
   job_class         =>  'TEST_CLASS',
   job_action        =>  'begin null; end;',
   start_date        =>  sysdate);
end;
/

begin
  dbms_scheduler.enable('TEST_JOB');
end;
/
 

Error starting at line 11 in command:
begin
  dbms_scheduler.enable('TEST_JOB');
end;
Error report:
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 2751
ORA-06512: at "SYS.DBMS_SCHEDULER", line 1794
ORA-06512: at line 2
27486. 00000 -  "insufficient privileges"
 
This was less trivial to find out, especially because I thought user TEST had created the job class, but it didn't.
Intestingly the first block is executed without problems, it's the enable procedure that is failing.

Then I carefully read the Oracle documentation for the DBMS_SCHEDULER.ENABLE procedure.
"For users to create jobs that belong to a job class, the job owner must have EXECUTE privileges on the job class. Therefore, after the job class has been created, EXECUTE privileges must be granted on the job class so that users create jobs belonging to that class."
 
So, if the user willing to schedule a job didn't create the job class, the user who created the job class must grant the EXECUTE privilege on the job class to the other user.

GRANT EXECUTE ON TEST_CLASS TO TEST; -- AS SYS or SYSTEM
 
The problem here was that I originally created the job classes with the TEST user, but then I exported and imported the schema as SYS, and I imagine something went wrong with the privileges (just my speculation thinking about the steps I made).

It resulted in a somewhat confusing situation where I couldn't immediately understand why I couldn't run a job even if I created it.

See message translations for ORA-27486 and search additional resources.

Monday, May 28, 2007

simple pager for Apex 3.0

Although i can claim that in the last 25 years i never got a phone call in the middle of the night for job reasons, i like to know as soon as possible when a major problem has occurred, especially if the error condition prevents users from doing their work.

However, if the application users are anonymous visitors of a web site, it can be difficult, if not impossible, to be contacted timely in case of problems that may arise for a variety of reason, including bugs at different levels, service outages, networking problems, unexpected usage patterns and so on.

If you are an Oracle Application Express developer or administrator you know that in the Monitor Activity section there is a useful built-in report displaying a list of unhandled exceptions that have occurred in the specified time frame, set by default to 1 day.

This report covers errors in the Apex domain, so we won't find any entries if the http server is down, that is when a user got a HTTP-404 error, but we will find entries if an Apex user got a broken report caused by an illegal parameter value, when an Apex process failed and the error was not trapped inside the program, including many other database related issues like a constraint violation or an exceeded tablespace quota that prevented the successful termination of a DML statement, always speaking in the context of Apex applications.

Clearly this approach implies an active participation on our side, because we must explicitly go to the Monitor Activity Page and run the report to know the information, and we know how easy is to forget a task when we have a busy agenda.

What I'm going to suggest here is a more passive approach that lets the computer do the work for us, that is in the end why these damned machines were invented in the first place.

The idea is to have a scheduled job that collects the information and sends us simple reports in form of emails at regular intervals.

Moreover, if you are using a mobile service provider integrating email and SMS, you can easily set up an automated paging system as i did.

And now for the real stuff.

As of Oracle Application Express version 3.0, we have finally all the required bits to carry out this task using supported objects, therefore we no longer need to have special privileges granted for accessing internal objects, in other words the most typical and least appreciated phrase in IT's history: "with the next software release you'll able to do that" has been fulfilled eventually.

Keeping in mind that that Oracle Application Express can still run on top of Oracle 9.2, where DBMS_SCHEDULER is not available, but DBMS_JOB is, i wrote a simple package that allows you to monitor the situation at regular intervals.

Of course the usual disclaimers apply, if you run a nuclear plant don't look at me if anything goes wrong with this program.

Note also that if you (or your DBA) revoked the execution privilege on DBMS_JOB package from PUBLIC (or from the schema user you are trying to compile the package into), the package compilation will fail.
If DBMS_JOB is disabled, that is parameter JOB_QUEUE_PROCESSES is set to zero (0), the pager will not be started, informing you via DBMS_OUTPUT that background jobs are disabled.

The procedures communicate messages via DBMS_OUTPUT and, hopefully, are self-explanatory.

I strongly recommend to perform these tasks from within the Apex environment, but you can do the same from sqlplus too, remembering to COMMIT whenever necessary.

The installation is straightforward, just download the SIMPLE_PAGER for Oracle Application Express 3.0 package and compile it in you schema.

Usage notes are provided in the package specification, however, once the packages have been compiled in the schema, the pager can be started within the next minute as follows:

begin
simple_pager.start_pager(
email => '...', -- comma separated list of recipients
email_from => '...', -- email of the sender
interval => 4 -- hours between each alert
);
end;
For instance if you prefer to receive the notifications periodically, on the hour, every 2 hours, starting from 12:00:00 (supposing now it's some time between 00:00 and 11:59:59), then you can specify the optional parameter next_alert, as follows:
begin
simple_pager.start_pager(
email => '...', -- comma separated list of recipients
email_from => '...', -- email of sender
interval => 2, -- hours between each alert
next_alert => trunc(sysdate) + 1/2 -- start at noon
);
end;

The pager can run without problems in a hosted environment, where each different workspace/user can run its own pager without interfering with others.

Hope it helps.

See more articles about Oracle Application Express or download tools and utilities.

Thursday, May 17, 2007

Invalid or unsupported parameter "JOB_QUEUE_INTERVAL"

If you worked with version 8i, you probably remember the initialization parameter JOB_QUEUE_INTERVAL.

Well, as of Oracle version 9.0.1 of Oracle RDBMS, this parameter has been made obsolete, as you can read in the Database Migration Guide for Oracle 9i Release 2, however there are several other books in the same library where this parameter is still referenced.

This means that if you have a program doing something like:

declare
intval binary_integer;
strval varchar2(255);
rtnval binary_integer;
begin
rtnval := DBMS_UTILITY.GET_PARAMETER_VALUE (
parnam => 'JOB_QUEUE_INTERVAL',
intval => intval,
strval => strval);
dbms_output.put_line(intval);
end;
it will end up with the following error:
ORA-20000: get_parameter_value: invalid or unsupported parameter "JOB_QUEUE_INTERVAL"
If you execute the following statement from SQL*Plus:
ALTER SYSTEM SET JOB_QUEUE_INTERVAL=60;
it will return:
ORA-25138: JOB_QUEUE_INTERVAL initialization parameter has been made obsolete
The last question concerns the default value that Oracle is using since JOB_QUEUE_INTERVAL has been discontinued: i could not find a document telling me if the value has been set to 60 seconds, the default value in Oracle 8i.

Note however that JOB_QUEUE_PROCESSES is still valid, albeit DBMS_JOB package has been deprecated and DBMS_SCHEDULER has been introduced.

---
ORA-25138: il parametro di inizializzazione è stato reso obsoleto
ORA-25138: el parámetro de inicialización está obsoleto
ORA-25138: el paràmetre d'inicialització ha estat fet obsolet
ORA-25138: le paramètre d'initialisation est obsolète
ORA-25138: Initialisierungsparameter ist veraltet
ORA-25138: η παράμετρος αρχικοποίησης είναι απαρχαιωμένη
ORA-25138: initialiseringsparameter er overflødig
ORA-25138: initieringsparametern har gjorts föråldrad
ORA-25138: initialiseringsparameter er foreldet
ORA-25138: alustusparametri on vanhentunut
ORA-25138: a(z) inicializálási paraméter már elavult
ORA-25138: parametrul de iniţializare nu mai este de actualitate
ORA-25138: Initialisatieparameter is verouderd.
ORA-25138: o parâmetro de inicialização se tornou obsoleto
ORA-25138: o parâmetro de inicialização tornou-se obsoleto
ORA-25138: параметр инициализации устарел
ORA-25138: zastaralý inicializační parametr
ORA-25138: iniciačný parameter sa stal zastaraným
ORA-25138: parametr inicjalizacji został zdezaktualizowany
ORA-25138: başlatma parametresi kullanılamaz olarak belirlenmiş
ORA-25138: initialization parameter has been made obsolete

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles