Problem with Dbms_Scheduler.Create_Job

Hi,
Below is my package, where in I am calling scheduler to run a job for the procedure written.
My Main Procedure: requests_delete_proc, deletes the requests which are more than 2 year old then sysdate.
I want to run a job monthly once for this procedure which is written under "delete_job".
This seems to be not working. I am not able to delete the records .
Can anyone suggest me as what is the problem pls?
CREATE OR REPLACE
PACKAGE BODY DELETE_REQUEST_PKG
AS
PROCEDURE requests_delete_proc
AS
request_count NUMBER;
nodatafound EXCEPTION;
BEGIN
SELECT
COUNT(request_id)
INTO
request_count
FROM
max_request_dtls
WHERE
requested_date < sysdate - (2*365);
IF request_count <> 0 THEN
DELETE
FROM
max_req_history_dtls
WHERE
request_id IN
SELECT
request_id
FROM
max_request_dtls
WHERE
requested_date < sysdate -(2 *365)
DELETE
FROM
max_request_dtls
WHERE
requested_date < sysdate -(2 * 365);
dbms_output.put_line('requests deleted');
COMMIT;
ELSE
raise nodatafound;
END IF;
EXCEPTION
WHEN nodatafound THEN
dbms_output.put_line('no records found for mentioned requested date');
END requests_delete_proc;
PROCEDURE delete_job
AS
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'request_Delete_job',
job_type => 'STORED_PROCEDURE',
job_action => 'Requests_Delete_Proc',
start_date => SYSTIMESTAMP,
repeat_interval => 'freq=MINUTELY',
end_date => NULL,
enabled => TRUE,
comments => 'Job defined entirely by the CREATE JOB procedure.');
END delete_job;
END DELETE_REQUEST_PKG;

Most probably your delete statement is faulty, otherwise it should work.
SQL>  CREATE TABLE emp_test_job AS SELECT * FROM emp;
Table created.
SQL> SELECT COUNT(*) FROM emp_test_job;
  COUNT(*)
        14
SQL> CREATE OR REPLACE PACKAGE DELETE_REQUEST_PKG AS
  2   PROCEDURE requests_delete_proc;
  3   PROCEDURE delete_job;
  4  END;
  5  /
SQL> CREATE OR REPLACE PACKAGE BODY DELETE_REQUEST_PKG AS
  2    PROCEDURE requests_delete_proc AS
  3      request_count NUMBER;
  4      nodatafound EXCEPTION;
  5    BEGIN
  6      DELETE FROM emp_test_job WHERE rownum<5;
  7    END requests_delete_proc;
  8 
  9    PROCEDURE delete_job AS
10    BEGIN
11      DBMS_SCHEDULER.create_job(job_name        => 'request_Delete_job',
12                                job_type        => 'PLSQL_BLOCK',
13                                job_action      => 'BEGIN DELETE_REQUEST_PKG.requests_delete_proc; END;',
14                                start_date      => SYSTIMESTAMP,
15                                repeat_interval => 'freq=MINUTELY',
16                                end_date        => NULL,
17                                enabled         => TRUE,
18                                comments        => 'Job defined entirely by the CREATE JOB procedure.');
19 
20    END delete_job;
21  END DELETE_REQUEST_PKG;
22  /
Package body created.
SQL>
SQL>  BEGIN
  2   DELETE_REQUEST_PKG.DELETE_JOB();
  3   END;
  4  /
PL/SQL procedure successfully completed.
SQL> SELECT job_name, program_name, start_date
  2  FROM all_scheduler_jobs;
JOB_NAME
PROGRAM_NAME
START_DATE
REQUEST_DELETE_JOB
29-NOV-10 05.38.10.703000 PM +05:30
SQL>  SELECT COUNT(*) FROM   emp_test_job;
  COUNT(*)
         6
SQL> SELECT COUNT(*) FROM   emp_test_job;
  COUNT(*)
         0
SQL> BEGIN
  2  DBMS_SCHEDULER.DROP_JOB('request_Delete_job',TRUE);
  3  END;
  4  /
PL/SQL procedure successfully completed.

Similar Messages

  • Problem with DBMS_SCHEDULER

    Hi All,
    I am getting error
    Error at line 1
    ORA-27452: user1.pkg_dummy.sp_dummy is an invalid name for a database object.
    ORA-06512: at "SYS.DBMS_ISCHED", line 679
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1130
    ORA-06512: at line 2
    BEGIN
    dbms_scheduler.create_schedule('user1.pkg_dummy.sp_dummy ', repeat_interval =>
    'FREQ=HOURLY;INTERVAL=1');
    END;
    But the package and procedure are available in user1 and in valid state.
    Is there any special grant to be given for package to be submited via job?
    Your responses are welcome.
    Regards,
    Tarak

    Hi
    I think you're using the wrong DBMS_SCHEDULER package. What you are doing with DBMS_SCHEDULER.CREATE_SCHEDULE is creating a schedule. You would then create a job to use that schedule.
    DBMS_SCHEDULER.CREATE_SCHEDULE
    schedule_name in varchar2,
    start_date in timestamp with timezone default null,
    repeat_interval in varchar2,
    end_date in timestamp with timezone default null,
    comments in varchar2 default null
    I think you're looking for:
    -- Job defined by an existing program and schedule.
    DBMS_SCHEDULER.create_job (
    job_name => 'test_prog_sched_job_definition',
    program_name => 'test_plsql_block_prog',
    schedule_name => 'test_hourly_schedule', <-- This would use the schedule created above
    enabled => TRUE,
    comments => 'Job defined by an existing program and schedule.');
    More info here:
    http://www.oracle-base.com/articles/10g/Scheduler10g.php
    Good luck!
    A.

  • Job scheduling using dbms_scheduler.create_job

    hi all experts,
    i am really grateful to you for your responses, now have a look at this, i have created a job with "dbms_scheduler.create_job" and blow is the output from view "dba_schduler_jobs" why it is showing run_count to '0'...i have gone through all provided links like:
    Answers to "Why are my jobs not running?"
    and applied and checked all parameters, i am using oracle 10.2.0.1.0 on windows server 2003 32-bit
    SQL> BEGIN
         DBMS_SCHEDULER.CREATE_JOB (
             job_name => 'clouser'
            ,job_type => 'PLSQL_BLOCK'
         ,job_action => 'begin package.procedure("po_closure"); end;'
         ,start_date => to_date('17-04-2009 22:00:00', 'dd-mm-yyyy hh24:mi:ss')
         ,repeat_interval => 'FREQ=DAILY;byminute=10'
         ,enabled => TRUE
         ,comments => 'op closure everyday at 11PM'
    END;
    PL/SQL procedure successfully completed.
    SQL> select owner,job_name name,run_count run,start_date
      2  from dba_scheduler_jobs
      3  where owner='FINANCEDEV';
    OWNER                          NAME                                  RUN
    START_DATE
    FINANCEDEV                     CLOUSER                                 0
    17-APR-09 02.45.10.000000 PM +05:30
    FINANCEDEV                     CLOUSER_MAIN                            0
    18-APR-09 10.25.00.000000 AM +05:30
    FINANCEDEV                     CLOUSER_MAIN1                           0
    18-APR-09 10.45.00.000000 AM +05:30
    OWNER                          NAME                                  RUN
    START_DATE
    FINANCEDEV                     CLOUSER_MAIN4                           0
    18-APR-09 10.45.00.000000 AM +05:30
    FINANCEDEV                     CLOUSER_MAIN5                           0
    18-APR-09 10.43.00.000000 AM +05:30the time i scheduled has already passed, and i am checking it again and again, but no luck,can you please explain why is it so??
    thanks in advance
    thanks and regards
    VD
    Edited by: vikrant dixit on Apr 17, 2009 10:33 PM

    Hello,
    I should have asked only for next_run_date and state and failure_count. Do you see any value for failure_count column. Seems you have a failure in running of this job and whereever are you , what's the time?
    You can also run this job manually using and see if run_count goes up or failure and it schedules the job for tommorrow as well.
    exec DBMS_SCHEDULER.RUN_JOB('CLOUSER',TRUE);Based on your information, your next_run_date should be set to 19 APr @ 12:10 AM.
    Here is example based on your information
    BEGIN
       sys.DBMS_SCHEDULER.create_job (
          job_name          => '"SCHEMA_NAME"."CLOUSER"',
          job_type          => 'PLSQL_BLOCK',
          job_action        => 'DECLARE
    begin
      po_closure varchar2(..) := ''some_value'';
      schema_name.package_name.procedure(po_closure);
    commit;
    end;
          repeat_interval   => 'FREQ=DAILY;BYMINUTE=10;BYSECOND=0',
          start_date        => SYSTIMESTAMP AT TIME ZONE 'US/Eastern',
          job_class         => 'DEFAULT_JOB_CLASS',
          auto_drop         => FALSE,
          enabled           => TRUE
       sys.DBMS_SCHEDULER.set_attribute (name        => '"SCHEMA_NAME"."CLOUSER"',
                                         attribute   => 'restartable',
                                         VALUE       => TRUE);
       sys.DBMS_SCHEDULER.enable ('"SCHEMA_NAME"."CLOUSER"');
    END;Regards

  • Dbms_scheduler.create_job problem

    Hello.
    I want to use dbms_scheduler.create_job in forms for progress_bar (http://fdegrelle.over-blog.com/article-10986844.html).
    But i get Dbms_scheduler.create_job must be declared message.
    If i connect to database as sys and check packages, dbms_scheduler is not among other packages.
    How do i install it? Is there a script?
    Thanks.

    DejanH,
    The PL/SQL code included in the sample dialog use both DBMS_SCHEDULER for 10g database and DBMS_JOB for 9i database..
    The DBMS_SCHEDULER is a 10g new feature. With a 9i version, you have to use the DBMS_JOB package:
    -- Lancement de la procédure par le package dbms_job pour la version 9i --
      If v_version = 9 Then
        dbms_job.isubmit(v_jobid,'Progress_Bar;',sysdate,null);
        forms_ddl('commit') ;
      Else
      -- Lancement de la procédure par le package dbms_scheduler pour la version 10g --
      dbms_scheduler.create_job(
        job_name   => v_jobname
       ,job_type   => 'stored_procedure'
       ,job_action => 'Progress_Bar'
       ,start_date => SYSDATE
       ,enabled    => TRUE
    ...In case of a 9i version, you have to comment all lines relative to the DBMS_SCHEDULER package ;-)
    Francois

  • Problems using dbms_scheduler with attached network disks

    Oracle 11.2.0.1
    I created a job which run  .bat - files.
    dbms_scheduler.create_job(
            job_name => 'JOB_FILES',
            job_type => 'EXECUTABLE',
            job_action => 'e:\dump\abc.bat',
            auto_drop => FALSE,
            enabled => TRUE);
    Content of abc.bat is
    "E:\Oracle\product\11.2.0\dbhome_1\BIN\7za a e:\dump\den3_arch_171020131420.zip x:\mtr\"
    Im trying to make an archive with files in some folder. In this example the folder is "x:\mtr\" where "x" is attached network disk.
    When i run this job It creates null archive and raises error
    ORA-27369: job of type EXECUTABLE failed with exit code: Incorrect function.
    If in "abc.bat" i change network disk "x" to server disk with existing folder all works properly(It archives all files).
    If i execute "abc.bat" from cmd window all works properly(It archives all files).
    Ive created java source
    create or replace and compile java source named "OSCommand" as
    import java.io.*;
    public class OSCommand{
    public static String Run(String Command){
    try{
    Process p = Runtime.getRuntime().exec(Command);
    p.waitFor();
    return("0");
    catch (Exception e){
    System.out.println("Error running command: " + Command +
    "\n" + e.getMessage());
    return(e.getMessage());
    and pl/sql function
    CREATE OR REPLACE FUNCTION OSCommand_Run(Command IN STRING)
    RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'OSCommand.Run(java.lang.String) return int';
    And it works like dbms_scheduler...
    May be user need any special grants?

    user617289 wrote:
    Thats right. How can i resolve this issue?
    when all else fails Read The Fine Manual
    DBMS_SCHEDULER

  • Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files

    GUIDE TO RUNNING EXTERNAL JOBS ON 10g WITH DBMS_SCHEDULER
    NOTE: Users using 11g should use the new method of specifying a credential which eliminates many of the issues mentioned in this note.
    This guide covers several common questions and problems encountered when using
    dbms_scheduler to run external jobs, either on Windows or on UNIX.
    What operating system (OS) user does the job run as ?
    External jobs which have a credential (available in 11g) run as the user
    specified in the credential. But for jobs without credentials including
    all jobs in 10gR1 and 10gR2 there are several cases.
    - On UNIX systems, in releases including and after 10.2.0.2 there is a file $ORACLE_HOME/rdbms/admin/externaljob.ora . All external jobs not in the SYS schema and with no credential run as the user and group specified in this file. This should be nobody:nobody by default.
    - On UNIX systems, in releases prior to 10.2.0.2 there was no "externaljob.ora" file. In this case all external jobs not in the SYS schema and with no credential run as the owner and group of the $ORACLE_HOME/bin/extjob file which should be setuid and setgid. By default extjob is owned by nobody:nobody except for oracle-xe where it is owned by oracle:oraclegroup and is not setuid/setgid.
    - On Windows, external jobs not in the SYS schema and with no credential run as the user that the OracleJobScheduler Windows service runs as. This service must be started before these jobs can run.
    - In all releases on both Windows and UNIX systems, external jobs in the SYS schema without a credential run as the oracle user.
    What errors are reported in SCHEDULERJOB_RUN_DETAILS views ?
    If a job fails, the first place to look for diagnostic information is the SCHEDULERJOB_RUN_DETAILS set of views. In 10gR2 and up the first 200 characters of the standard error stream is included in the additional_info column.
    In all releases, the error number returned by the job is converted into a
    system error message (e.g. errno.h on UNIX or net helpmsg on Windows) and that
    system error message is recorded in the additional info column. If there is no
    corresponding message the number is displayed.
    In 11g and up the error number returned by the job is additionally recorded in
    the error# column. In earlier releases 27369 would always be recorded in the
    error# column.
    Generic Issues Applicable to UNIX and Windows
    - The job action (script or executable) must return 0 or the job run will be marked as failed.
    - Always use the full pathname to executables and scripts.
    - Do not count on environment variables being set in your job. Make sure that the script or executable that your jobs runs sets all required environment variables including ORACLE_HOME, ORACLE_SID, PATH etc.
    - It is not recommended to pass in a complete command line including arguments as the action. Instead it is recommended to pass in only the path to and name of the executable and to pass in arguments as job argument values.
    - Scripts with special characters in the execution path or script name may give problems.
    - Ensure that the OS user your job runs as has the required privileges/permissions to run your job. See above for how to tell who the job runs as.
    - External job actions cannot contain redirection operators e.g. > < >> | && ||
    - In general try getting a simple external job working first e.g. /bin/echo or ipconfig.exe on Windows. Also try running the job action directly from the commandline as the OS user that the job will run as.
    Windows-specific Issues
    - The OracleJobScheduler Windows service must be started before external jobs will run (except for jobs in the SYS schema and jobs with credentials).
    - The user that the OracleJobScheduler Windows service runs as must have the "Log on as batch job" Windows privilege.
    - A batch file (ending in .bat) cannot be called directly by the Scheduler. Instead cmd.exe must be used and the name of the batch file passed in as an argument. For example
    begin
    dbms_scheduler.create_job('myjob',
       job_action=>'C:\WINDOWS\SYSTEM32\CMD.EXE',
       number_of_arguments=>3,
       job_type=>'executable', enabled=>false);
    dbms_scheduler.set_job_argument_value('myjob',1,'/q');
    dbms_scheduler.set_job_argument_value('myjob',2,'/c');
    dbms_scheduler.set_job_argument_value('myjob',3,'c:\temp\test.bat');
    dbms_scheduler.enable('myjob');
    end;
    /- In 10gR1 external jobs that wrote to standard output or standard error streams would sometimes return errors. Redirect to files or suppress all output and error messages when using 10gR1 to run external jobs.
    UNIX-specific Issues
    - When running scripts, make sure that the executable bit is set.
    - When running scripts directly, make sure that the first line of the script in a valid shebang line - starting with "#!" and containing the interpreter for the script.
    - In release 10.2.0.1, jobs creating a large amount of standard error text may hang when running (this was fixed in the first 10.2.0.2 patchset). If you are seeing this issue, redirect standard error to a file in your job. This issue has been seen when running the expdp utility which may produce large amounts of standard error text.
    - the user that the job runs as (see above section) must have execute access on $ORACLE_HOME/bin and all parent directories. If this is not the case the job may be reported as failed or hang in a running state. For example if your $ORACLE_HOME is /opt/oracle/db then you would have to make sure that
    chmod a+rx /opt
    chmod a+rx /opt/oracle
    chmod a+rx /opt/oracle/db
    chmod a+rx /opt/oracle/db/bin
    - On oracle-xe, the primary group of your oracle user (if it exists) must be dba before you install oracle-xe for external jobs to work. If you have an oracle user from a regular Oracle installation it may have the primary group set to oinstall.
    - On oracle-xe, the extjobo executable is missing so external jobs in the SYS schema will not work properly. This can be fixed by copying the extjob executable to extjobo in the same directory ($ORACLE_HOME/bin).
    - Check that correct permissions are set for external job files - extjob and externaljob.ora (see below)
    Correct permissions for extjob and externaljob.ora on UNIX
    There is some confusion as to what correct permissions are for external job related files.
    In 10gR1 and 10.2.0.1 :
    - rdbms/admin/externaljob.ora should not exist
    - bin/extjob should be setuid and setgid 6550 (r-sr-s---). It should be owned by the user that jobs should run as and by the group that jobs should run as.
    - bin/extjobo should have normal 755 (rwxr-xr-x) permissions and be owned by oracle:oraclegroup
    In 10.2.0.2 and higher
    - rdbms/admin/externaljob.ora file must must be owned by root:oraclegroup and be writable only by the owner i.e. 644 (rw-r--r--) It must contain at least two lines: one specifying the run-user and one specifying the run-group.
    - bin/extjob file must be also owned by root:oraclegroup but must be setuid i.e. 4750 (-rwsr-x---)
    - bin/extjobo should have normal 755 (rwxr-xr-x) permissions and be owned by oracle:oraclegroup
    In 11g and higher
    Same as 10.2.0.2 but additionally bin/jssu should exist with root setuid
    permissions i.e. owned by root:oraclegroup with 4750 (-rwsr-x---)
    Internal Error numbers for UNIX on 10.2.0.2 or 10.1.0.6 or higher
    If you are not using a credential and are using version 10.2.0.2 or higher or 10.1.0.6 or higher you may come across an internal error number. Here are the meanings for the internal error numbers.
    274661 - can't get owner of or permissions of externaljob.ora file
    274662 - not running as root or externaljob.ora file is writable by group or other or externaljob.ora file not owned by root (can't switch user)
    274663 - setting the group or effective group failed
    274664 - setting the user or effective user failed
    274665 - a user or group id was not changed successfully
    274666 - cannot access or open externaljob.ora file
    274667 - invalid run_user specified in externaljob.ora file
    274668 - invalid run_group specified in externaljob.ora file
    274669 - error parsing externaljob.ora file
    274670 - extjobo is running as root user or group

    Hi Ravi,
    Can you help me...
    Hi All,
    I planned to create a job to do rman backup daily at 04:00 AM.
    1. I created a program as follows
    BEGIN
    DBMS_SCHEDULER.CREATE_PROGRAM(
    program_name => 'rman_backup_prg',
    program_action => '/u02/rmanback/rman.sh',
    program_type => 'EXECUTABLE',
    comments => 'RMAN BACKUP');
    END;
    my rman script is
    #!/usr/bin/ksh
    export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
    export PATH=$PATH:/u01/app/oracle/product/10.2.0/db_1/bin
    /u01/app/oracle/product/10.2.0/db_1/bin/exp rman/cat@catdb file=/u02/rmanback/rm
    an_220108.dmp log=/u02/rmanback/rman_220108.log owner=rman statistics=none comp
    ress=n buffer=400000
    compress *.dmp
    exit
    2. I created a schedule as follows
    BEGIN
    DBMS_SCHEDULER.CREATE_SCHEDULE(
    schedule_name => 'rman_backup_schedule',
    start_date => SYSTIMESTAMP,
    end_date => '31-DEC-16 05.00.00 AM',
    repeat_interval => 'FREQ=DAILY; BYHOUR=4',
    comments => 'Every day at 4 am');
    END;
    3. I created ajob as follows.
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'rman_backup_job',
    program_name => 'rman_backup_prg',
    schedule_name => 'rman_backup_schedule',
    enabled=> true,
    auto_drop=> false
    END;
    While I am running the job I am getting the following error anybody help me.
    ORA-27369: job of type EXECUTABLE failed with exit code: Not owner
    ORA-06512: at "SYS.DBMS_ISCHED", line 150
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
    ORA-06512: at line 2
    If I removed "compress *.dmp" line in rman script it is working fine.
    /* additional Info from dba_scheduler_job_run_details as follows */
    ORA-27369: job of type EXECUTABLE failed with exit code: Not owner
    STANDARD_ERROR="
    Export: Release 10.2.0.3.0 - Production on Tue Jan 22 14:30:08 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to: Oracle Database 10g Release 10.2.0.3.0 - Production
    Export"
    Regards,
    Kiran

  • Error with dbms_scheduler and shell script execution

    Hi,guys.
    I have an issue with a dbms_scheduler and a shell script execution. So, the shell script as it self works fine, when i'm executing ./test.sh all process is running, but when i'm executing the script from dbms_scheduler it just simply doesn't work. Actually it works, but some of executable information in sh doesn't work, seems it just jump over of the part of the script. Sendmail part is running, maybe there is problem with rman script as it self?
    DB version: 10g
    And my scripts:
    Shell scripts (permisons 755):
    #!/bin/ksh
    export PATH=/home/oracle/product/asm_home/bin:/home/oracle/product/db_home/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/oracle/bin:/usr/bin/X11:/sbin:.
    export ORACLE_BASE=/home/oracle/product
    export ORACLE_SID=zabbix
    export ORACLE_HOME=/home/oracle/product/db_home
    ${ORACLE_HOME}/bin/rman<<EOF
    connect target /
    run {backup recovery area delete all input;}
    EOF
    {       echo "From:[email protected]"
            echo "To: [email protected]"
            echo "Subject: Recovery area"
            echo 'Content-Type: text/html'
            echo
            echo '<html><body><table border="1" cellspacing="1">'
            echo '<tr><td><b>Process</b></td><td><b>Statuss</b></td></tr>'
            echo "<tr><td>RMAN</td><td><b>Works</b></td></tr>"
            echo "</table></body></html>"
    } | sendmail -tIn the first part i'm exporting all of the important stuff for oracle, then I call RMAN with specific atributes. And then there is just simply sendmail functionality inside script to represent if script works (for now).
    And below pl/sql script:
    begin
      DBMS_SCHEDULER.CREATE_JOB
      job_name => 'FLASH_RECOVERY',
      job_type => 'EXECUTABLE',
      job_action => '/home/oracle/backup/test.sh',
      start_date => sysdate,
      job_class => 'DEFAULT_JOB_CLASS',
      enabled => TRUE,
      auto_drop => FALSE,
      comments => 'FLASH RECOVERY USAGE AREA backup and delete'
      END;
      /And this job execution:
           begin
               DBMS_SCHEDULER.run_job (job_name =>'FLASH_RECOVERY',use_current_session => TRUE);
           end;What can be wrong? For me, I think it's something with permisions.
    I hope you got my idea and could help me.
    Tom
    Edited by: safazaurs on 2013.18.2 22:16

    There is no error, i just receive all the time e-mail, seems it jumps over rman. I tried almost everything and still couldn't get result as i want. And, if i'm running script from command line - it works. Rman calls, and starts to recover archivelogs.

  • How to use dbms_Scheduler.Create_Job from within stored procedure?

    Hello,
    using 10g (10.1.0.2.0) on Windows 2000 I had problems to create scheduler jobs from within a stored procedure (see example below). What easily succeeds using anonymous blocks failed when calling from a stored procedure, due to ORA-27486. Only when I compile the procedure with invoker's rights the call to dbms_Job.Create_Job is successfull!? From my knowledge there is no difference between invoker's and definer's rights, if I compile and call with the same user, is there?
    Does anyone know the reason for this behaviour or is it simply a bug?
    Have a nice day.
    Björn Hachmann
    Hamburg / Germany
    -- Example start.
    create table t
    a number(1),
    b date default sysdate
    create or replace procedure sched1
    is
    begin
    dbms_scheduler.create_job(
    job_name => 'TEST_JOB1',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN insert into t values (1); END;',
    repeat_interval => 'freq=secondly',
    enabled => TRUE
    commit;
    end;
    create or replace procedure sched2
    authid current_user
    is
    begin
    dbms_scheduler.create_job(
    job_name => 'TEST_JOB2',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN insert into t values (2); END;',
    repeat_interval => 'freq=secondly',
    enabled => TRUE
    commit;
    end;
    exec sched1; -- This call fails with ORA-27486.
    exec sched2; -- This call succeeds!
    /* Cleanup.
    exec dbms_scheduler.drop_job('TEST_JOB1', true);
    exec dbms_scheduler.drop_job('TEST_JOB2', true);
    drop table t;
    */

    Your example code ran without problems for me on 10.1.0.3.0 so it probably is a bug.

  • Maximum size of dbms_scheduler.create_job job_action parameter

    i'm running into a problem with the size limit for the dbms_job.submit what parameter... time to move to the dbms_scheduler.create_job package?
    can anyone tell me what the maximum size is for the dbms_scheduler.create_job job_action parameter?
    appreciate any information that can be provided.

    Herald ten Dam wrote:
    But how doy come in trouble with this length, normally a call to a procedure (in a package) and do there the job. Don't program the whole pl/sql (C/Java) in the call. With dbms_scheduler you can make also dependencies between jobs, so it is possible to split the functionality.Yes, I completely agree. The only times that I've put PL/SQL anonymous blocks in scheduler actions is when I want to guarantee the fewest dependencies for jobs (or chain steps) that are really critical, such as when you want to send an email or other notification that a failure has occurred. Otherwise I'd just call a procedure.

  • Creating backup Job with DBMS_SCHEDULER

    Hello,
    Can someone please help me out here:
    I'm using Oracle10g release 1 on windowsXP
    I'm trying to create a backup job with dbms_scheduler and it's not working.
    This is what I did:
    I created a job as follows:
    BEGIN
    dbms_scheduler.create_job (
    job_name => 'RMAN_FULL',
    job_type => 'EXCUTABLE',
    job_action => 'E:\wkdir\rman_bkp',
    enabled => TRUE,
    start_date => '24-NOV-2007 2:10:00 PM',
    repeat_interval => 'FREQ=WEEKLY',
    comments => 'Full Database Backup');
    END;
    While rman_bkp is an RMAN command but it wasn't working.
    Please where do I get it wrong?
    Kindly put me through the EXECUTABLE or should I use PL/SQL_BLOCK and how?
    Thanks.
    Regards,
    Cherish

    Hi,
    There is a guide to running external jobs using the Scheduler here
    Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files
    You need to use the full path to a real Windows executable and the arguments to it e.g. for a batch script you would have to do something like
    c:\windows\cmd.exe /q /c c:\myscript.bat
    There is a forum dedicated to the Scheduler here
    Scheduler
    Hope this helps,
    Ravi.

  • How to use NULL as an argument in a dbms_scheduler.create_job script?

    Hello All,
    We are trying to pass a null argument as a parameter to a PL/SQL program after CURRENT_TIMESTAMP. However, every attempt we try is producing errors. Why we are passing the null is another story. Does anyone know of the correct syntax, if there is any, to accomplish passing the null argument as a parameter to a PL/SQL program?
    We'd like to continue running with this same script setup and have the passing of the null working.
    This is what we've tried and directly below are the results. Any help so far would be appreciated!
    begin
    dbms_scheduler.create_job ( job_name => 'LOAD_CRF_TRANSACTION',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin
    DW_CRF.PKG_LPS_CRF_LOAD_TRANS.sp_load_target(''LOAD_CRF'', ''LOAD_LOAN_TRAN'', CURRENT_TIMESTAMP, );
    end;',
    start_date => sysdate +1/24/59,
    enabled => TRUE,
    auto_drop => TRUE,
    comments => 'LOAD LOAN TRANSACTION TABLE IN DW_CRF ' );
    end;
    ORA-06550: line ORA-06550: line 2, column 115:
    PLS-00103: Encountered the symbol ")" when expecting one of the following:
    ( - + case mod new not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    <an alternatively-quoted string literal with character set specification>
    <an alternatively-q
    , column :
    begin
    dbms_scheduler.create_job ( job_name => 'LOAD_CRF_TRANSACTION',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin
    DW_CRF.PKG_LPS_CRF_LOAD_TRANS.sp_load_target(''LOAD_CRF'', ''LOAD_LOAN_TRAN'', CURRENT_TIMESTAMP);
    end;',
    start_date => sysdate +1/24/59,
    enabled => TRUE,
    auto_drop => TRUE,
    comments => 'LOAD LOAN TRANSACTION TABLE IN DW_CRF ' );
    end;
    ORA-06550: line ORA-06550: line 2, column 21:
    PLS-00306: wrong number or types of arguments in call to 'SP_LOAD_TARGET'
    ORA-06550: line 2, column 21:
    PL/SQL: Statement ignored
    , column :
    begin
    dbms_scheduler.create_job ( job_name => 'LOAD_CRF_TRANSACTION',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin
    DW_CRF.PKG_LPS_CRF_LOAD_TRANS.sp_load_target(''LOAD_CRF'', ''LOAD_LOAN_TRAN'', CURRENT_TIMESTAMP, NULL);
    end;',
    start_date => sysdate +1/24/59,
    enabled => TRUE,
    auto_drop => TRUE,
    comments => 'LOAD LOAN TRANSACTION TABLE IN DW_CRF ' );
    end;
    ORA-20050: ORA-20050: Error Loading PKG_LPS_CRF_LOAD_TRANS Data
    ORA-06512: at "DW_CRF.PKG_LPS_CRF_LOAD_TRANS", line 958
    ORA-06512: at line 2
    begin
    dbms_scheduler.create_job ( job_name => 'LOAD_CRF_TRANSACTION',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin
    DW_CRF.PKG_LPS_CRF_LOAD_TRANS.sp_load_target(''LOAD_CRF'', ''LOAD_LOAN_TRAN'', CURRENT_TIMESTAMP, "NULL");
    end;',
    start_date => sysdate +1/24/59,
    enabled => TRUE,
    auto_drop => TRUE,
    comments => 'LOAD LOAN TRANSACTION TABLE IN DW_CRF ' );
    end;
    ORA-01858: a non-numeric character was found where a numeric was expected

    Hi,
    The third syntax you used is correct i.e.
    DW_CRF.PKG_LPS_CRF_LOAD_TRANS.sp_load_target(''LOAD_CRF'', ''LOAD_LOAN_TRAN'', CURRENT_TIMESTAMP, NULL);
    Alternatively you can use
    DW_CRF.PKG_LPS_CRF_LOAD_TRANS.sp_load_target(''LOAD_CRF'', ''LOAD_LOAN_TRAN'', CURRENT_TIMESTAMP, '''');
    all the other calls give syntax errors that are expected. The third call is giving an application error which you will need to look into (maybe starting at "DW_CRF.PKG_LPS_CRF_LOAD_TRANS", line 958). One thing that may help clarify things is if you were to switch to naming your parameters e.g. target_name=>''LOAD_CRF'' since that helps clarify exactly what parameter is called with which value.
    Hope this helps,
    Ravi.

  • Button process with DBMS_SCHEDULER.run_job

    Hi,
    I need to execute the DBMS_SCHEDULER.run_job on click of a button .
    I tried creating a process (On submit) with DBMS_SCHEDULER.run_job('JOBNAME')
    when i tried executing directly in db there is no problem, but when i create the process in apex i am running into the following error
    ORA-06550: line 2, column 19: PLS-00222: no function with name 'RUN_JOB' exists in this scope ORA-06550: line 2, column 1: PL/SQL: Statement ignored
    Anybody have tried this before?? is there a way around or am i getting this wrong?
    Thanks,

    Resolved,
    I had to specify the current session state while executing the scheduler job
    In my case i made it false
    BEGIN
    -- Run job synchronously.
    DBMS_SCHEDULER.run_job (job_name => 'JobName',
    use_current_session => FALSE);
    END;
    Thanks

  • DBMS_SCHEDULER.CREATE_JOB executing a shell script

    Hi ,
    Shell script :-  TEST.ksh
    #!/bin/ksh
    dhxmlfile=`date +"%Y-%j-%R"`
    dhoriginfile= /A/XMLFirstTest.xml
    dhdestinationfile=/A/B
    cp $dhoriginfile $dhdestinationfile/$dhxmlfile
    rm $dhoriginfile
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB
    (job_name=>'TEST.ksh',
      job_type=>'EXECUTABLE',
    JOB_ACTION=>'/A/TEST.ksh',
    Start_date=> SYSDATE,
    job_class=> 'DEFAULT_JOB_CLASS',
    Enabled=> TRUE,
    auto_drop=> TRUE,
    Comments=> 'Run shell-script Test.ksh');
    Exception
    WHEN others then
    DBMS_OUTPUT.PUT_LINE
    (SQLCODE||SQLERRM);
    end;
    Getting an error :-
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    STANDARD_ERROR="Oracle Scheduler error: Config file is not owned by root or is writable by group or other or extjob is not setuid and owned by root"
    Can anyone help me with this

    Can anyone help me with this
    No - not in this forum. This forum, as the title says, is for Sql developer questions.
    Please mark the question ANSWERED and repost it in the SQL and PL/SQL forum
    https://community.oracle.com/community/developer/english/oracle_database/sql_and_pl_sql

  • Problem With Creating a Huge HTML document In Portal

    Hallo,
    I am trying to insert a 735 lines long HTML into Portal. When I press the finish button I get the following error message:
    The requested URL /pls/portal30/PORTAL30.wwv_builder.accept was not found on this server.
    If I then go back and take out one of the forms I have in the HTML file and press the finish button, Portal accepts this.
    I am sure the problem is related to the size and not code because I have tested the form alone in Portal and it works.
    Would anyone know of a way around this problem?

    when i write the tow statements the first one didn't run but the second one run
    SQL> select to_timestamp('02/04/08 11:00:00.00 AM', 'DD/MM/RR HH12:MI:SS.FF PM') from dual;
    select to_timestamp('02/04/08 11:00:00.00 AM', 'DD/MM/RR HH12:MI:SS.FF PM') from dual
    ERROR at line 1:
    ORA-01855: AM/A.M. or PM/P.M. required
    SQL> select to_timestamp('02/04/08 11:00:00.00', 'DD/MM/RR HH24:MI:SS.FF') from dual;
    TO_TIMESTAMP('02/04/0811:00:00.00','DD/MM/RRHH24:MI:SS.FF')
    02/04/08 11:00:00.000000000 Õ
    when i used the second one in the job this error appear
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'first_job',
    job_type => 'executable',
    job_action => 'C:\Documents and Settings\mohamed.sallam\Desktop\Calculator.lnk',
    start_date => 'to_timestamp('02/04/08 11:00:00.00', 'DD/MM/RR HH24:MI:SS.FF')',
    repeat_interval => 'FREQ=HOURLY;INTERVAL=12',
    end_date => 'to_timestamp('02/04/09 11:00:00.00', 'DD/MM/RR HH24:MI:SS.FF')',
    comments => '-------');
    END;
    0552: Bind variable "MI" not declared.

  • Error with dbms_scheduler

    Hi,
    i am getting an unknown command error when i am trying to create a scheduled job. Here is my call:
    dbms_scheduler.create_job( job_name=> 'reset_sync_sequnces', job_type=>'PLSQL_BLOCK',
    job_action=> 'begin
    RAM_SYNC.RESET_SEQ(''SYNC_SALE'');
    RAM_SYNC.RESET_SEQ(''SYNC_PYMNT'');
    RAM_SYNC.RESET_SEQ(''SYNC_SUSACCT'');
    end;',
    start_date=> sysdate, repeat_interval=> 'freq=daily;interval=1;byhour=0; byminute=0; bysecond=0;', enabled=> true);
    Error starting at line 1 in command:
    dbms_scheduler.create_job( job_name=> 'reset_sync_sequnces', job_type=>'PLSQL_BLOCK',
    Error report:
    Unknown Command
    Thanks for the help

    In what tool are you issuing this command?
    Sqlplus?
    Then you should preceed it with the 'execute' keyword (or 'exec' in short). Or embed the dbms_scheduler call inside an anonymous plsql block.

Maybe you are looking for

  • Running a report on QAS that requires changes to structures

    Hi, I am trying to apply an OSS Note but the the note saids the following: <i>You must therefore execute the report in each system in the system infrastructure.</i> Would this be referring to running the report on the QAS and PRD systems? I ran the r

  • Problem when updating dhcpcd file

    My internet is working fine except when i update the dhcpcd file i can't access a lot of server or site. Example, i use the gatech server with pacman but after the dhcpcd update i can't. I can visit the archlinux website but not his wiki or forum...

  • Error occurred while contact store

    I cannot seem to order a book I created in iphoto '11.  Can someone guide me on what I might be doing wrong.

  • Pass additional parameter to SOAP header?

    We are using webservice datawindows to pass request xmls to call webservices. Additionally we use 'wsconnection' objects authenticationmode, username and password property to send information to SOAP header. Now we have to send one more value to SOAP

  • Transact SQL Query

    Hi, We are using sql server 2012. This query is used by financial applications. Each client has multiple accounts. There will be multiple transactions happening on each account (like deposit, withdrawal, sale money, internal transfers etc). Eg: Trans