Dbms_scheduler

hi ,
     what's up,guys?i need your favor,i scheduled my materialized view for refreshing using dbms_scheduler but it is not updating my view whenever there is an update in my table,kindly help.
thanks in advance.
sql>CREATE MATERIALIZED VIEW LOG ON t1;
sql>create materialized view t1mv refresh on demand
    as
    (select a.ename,a.job,b.dname from t1 a,dept b where a.deptno=b.deptno);
BEGIN
  DBMS_SCHEDULER.CREATE_JOB (
    JOB_NAME        => 't1_MV_REFRESH',
    JOB_TYPE        => 'PLSQL_BLOCK',
    JOB_ACTION        => 'BEGIN mv_refresh_job(''EXEC DBMS_MVIEW.REFRESH(''T1MV'', ''F'')''); END;',
    START_DATE      => SYSTIMESTAMP,
    REPEAT_INTERVAL => 'freq=minutely; bysecond=0;',
    END_DATE        => NULL,
    ENABLED         => TRUE,
    COMMENTS        => 'Refreshes Materialized Views on a Scheduled Basis');
END;
thanks and regards.
os;rhel6
db:11.2.0.3

We don't know what your procedure mv_refresh_job is doing.
Why you don't simply call dbms_mview.refresh directly ?
BEGIN
  DBMS_SCHEDULER.CREATE_JOB (
    JOB_NAME        => 't1_MV_REFRESH',
    JOB_TYPE        => 'PLSQL_BLOCK',
    JOB_ACTION        => 'BEGIN DBMS_MVIEW.REFRESH(''T1MV'', ''F''); END;',
    START_DATE      => SYSTIMESTAMP,
    REPEAT_INTERVAL => 'freq=minutely; bysecond=0;',
    END_DATE        => NULL,
    ENABLED         => TRUE,
    COMMENTS        => 'Refreshes Materialized Views on a Scheduled Basis');
END;
or you can use refresh clause when creating MV.
When you call dbms_mview.refresh('T1MV','F'); from SQL*Plus what's the result ?

Similar Messages

  • Error While Running DBMS_SCHEDULER.RUN_JOB in Oacle 11g DB in LINUX ENvirnoment

    Dear ALL,
    I have two separate Server, One is App. Server which is on WINDOWS 2008 and the DB server on LINUX. I'm created a job for Daily logical Backup of Database through EXP command on DB Server.
    I have created DBMS_SCHEDULER.CREATE_JOB with JOB_ACTION /home/oracle/wms_dbdmp/auto_backup.sh the Location of .sh file which contain the following code
    #!/bin/bash
    exp test/test@orcl file=/home/oracle/wms_dbdmp/test.dmp log=/home/oracle/wms_dbdmp/test.log compress=N rows=Y grants=Y owner=(test) statistics=NONE
    ECHO "Export done successfully..."
    Exit 0
    Now i created job successfully, but when i'm invoking this .sh file through DBMS_SCHEDULER>RUN_JOB('backup_01');
    I'm facing error which are given as-
    ORA-27369: job of type EXECUTABLE failed with exit code: Permission denied
    ORA-06512: at "SYS.DBMS_ISCHED", line 185
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 486
    ORA-06512: at line 1
    I did this on WINDOWS Environment Successfully. I'm naive user for LINUX Envirnoment SO Please Guide me to rid off to this problem.
    I will be very thank full to all...

    I wrote the script as
    #!/bin/bash
    exp test/test@orcl file=/home/oracle/wms_dbdmp/test.dmp log=/home/oracle/wms_dbdmp/test.log compress=N rows=Y grants=Y owner=(test) statistics=NONE
    exit 0
    But it didn't work through procedure....how to invoke .sh file through db procedure...?

  • 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

  • Stored Proc running twice using DBMS_Scheduler

    Hello all,
    I have a vb front end that calls a main stored proc which submits scheduler jobs to execute several stored procs asynchronously. Everything is working, except the part that the several stored procs are running twice. In the troubleshooting, I have eliminated the front end from being the culprit and the stored procs themselves. Essentially, when I call the stored proc using dbms_scheduler.create_job, it runs twice, even manually. I am about at wits end trying to figure out why: Using Oracle 11gR2
    I started off setting up the programs
    begin
    --create program
    dbms_scheduler.create_program
    ( program_name => 'prog_name'
    ,program_type => 'STORED_PROCEDURE'
    ,program_action => 'usp_sub_proc_1'
    ,number_of_arguments => 8
    ,enabled => FALSE
    dbms_scheduler.DEFINE_PROGRAM_ARGUMENT
    ( program_name=> 'prog_name'
    ,argument_position=>1
    ,argument_name => 'name'
    ,argument_type=>'VARCHAR2'
    /*the remaining 7 arguments are in code but not display for space reasons*/
    dbms_scheduler.enable('prog_name');
    end;Then the main stored proc executes this code:
    declare v_job_name varchar2(100);
        v_1 varchar(50) := 'All';
        v_2 varchar(50) := 'All';
        v_3 varchar(50) := 'All';
        v_4 varchar(50) := 'All';
        v_5 varchar(50) := 'TEST';
        i_6 integer := 1;
        v_7 varchar(50) := 'TEST_NE';
        ts_8 timestamp := current_timestamp;
    begin
        v_job_name := 'uj_dmo_1';
    dbms_scheduler.create_job (v_job_name
                                            ,program_name => 'prog_name'
                                            ,job_class => 'UCLASS_1'
                                            ,auto_drop => TRUE
    --set parameters
    dbms_scheduler.set_job_argument_value(v_job_name,1, v_1);
    dbms_scheduler.set_job_argument_value(v_job_name,2, v_2);
    dbms_scheduler.set_job_argument_value(v_job_name,3, v_3);
    dbms_scheduler.set_job_argument_value(v_job_name,4, v_4);
    dbms_scheduler.set_job_argument_value(v_job_name,5, v_5);
    dbms_scheduler.set_job_argument_value(v_job_name,6, to_char(i_6));
    dbms_scheduler.set_job_argument_value(v_job_name,7, v_7);
    dbms_scheduler.set_job_argument_value(v_job_name ,8, to_char(ts_8));
    --enable job
    dbms_scheduler.enable(v_job_name);
    --execute job
    dbms_scheduler.run_job(job_name => v_job_name , use_current_session => FALSE);
    end;
    ...And this is where I get the double execution of the job, but I am just not seeing it in my syntax, dba_scheduler_jobs, logging, etc. Any help is greatly appreciated, thanks!!

    Well apparently I will not win any Captain Obvious awards;
    With 34MCA2K2's response with "what doesn't work" for some reason turned the light on. After some more testing here is what I found.
    This code works as expected :
    Exhibit A
    begin
    dbms_scheduler.create_job (job_name =>'TESTER'
                                   ,job_type => 'PLSQL_BLOCK'
                                   ,job_action => 'declare test1 integer := 1; begin test1 := test1 + 5; end;'
                                   ,auto_drop => True
       /*dbms_scheduler.enable('TESTER');   */
       dbms_scheduler.run_job(job_name => 'TESTER', use_current_session =>FALSE);   
    end;As does this:
    Exhibit B
    begin
    dbms_scheduler.create_job (job_name =>'TESTER'
                                   ,job_type => 'PLSQL_BLOCK'
                                   ,job_action => 'declare test1 integer := 1; begin test1 := test1 + 5; end;'
                                   ,auto_drop => True
       dbms_scheduler.enable('TESTER');  
      /*dbms_scheduler.run_job(job_name => 'TESTER', use_current_session =>FALSE);    */
    end;Exhibit A will create the job and is visible in the schedulerjobs view, and the RUN_JOB will execute it even when not enabled, but the pl/sql will not drop the job.
    Exhibit B will create the job and once enabled, executes the job and then drops from schedulerjobs view.
    Therefore, my desired results for running the jobs once asynchronously and dropping immediately is....
    begin
        v_job_name := 'uj_dmo_1';
    dbms_scheduler.create_job (v_job_name
                                            ,program_name => 'prog_name'
                                            ,job_class => 'UCLASS_1'
                                            ,auto_drop => TRUE
    --set parameters
    dbms_scheduler.set_job_argument_value(v_job_name,1, v_1);
    dbms_scheduler.set_job_argument_value(v_job_name,2, v_2);
    dbms_scheduler.set_job_argument_value(v_job_name,3, v_3);
    dbms_scheduler.set_job_argument_value(v_job_name,4, v_4);
    dbms_scheduler.set_job_argument_value(v_job_name,5, v_5);
    dbms_scheduler.set_job_argument_value(v_job_name,6, to_char(i_6));
    dbms_scheduler.set_job_argument_value(v_job_name,7, v_7);
    dbms_scheduler.set_job_argument_value(v_job_name ,8, to_char(ts_8));
    /*enable job*/
    dbms_scheduler.enable(v_job_name);
    /*execute job (Do not execute the code below, it will lead to multiple executions)
    dbms_scheduler.run_job(job_name => v_job_name , use_current_session => FALSE); */
    end;

  • 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.

  • Creating a job with DBMS_SCHEDULE  from Forms?

    I'm new to DBMS_SCHEDULER. I'd like to run a stored procedure from an Oracle Forms application passing some parameters from the Form to the procedure, then immediately running the procedure and after the procedure has finished dropping it from the job list. The procedure may take some time to run and the user doesn't want to wait before exiting the form. Can this be done?

    Sure, no problem. The job will be dropped after termination by default (autodrop). If privileges are ok it should work. Things to think about are error reporting and retries.
    regards,
    Ronald
    http://ronr.nl/unix-dba

  • Error in creating job using DBMS_SCHEDULER

    I have create the following procedure to create individual jobs dynamically on each schema.
    CREATE OR REPLACE PROCEDURE APSP.JOB_TEST_RAM
    AS
       V_SQL   VARCHAR2 (1000);
    BEGIN
       FOR i
       IN (SELECT   gbm.OWNER_NAME owner_name,
                    vdb.NAME || '_BU_' || gbm.BU_CODE,
                    gbm.bu_id bu_id
             FROM   apps_global.GLOBAL_BU_MAPPING gbm, v$database vdb
            WHERE   OWNER_NAME NOT IN ('APPS_GLOBAL'))
       LOOP
          V_SQL :=
             'BEGIN
                  DBMS_SCHEDULER.CREATE_JOB (
                      job_name => '''
             || i.owner_name
             || '_archive_job'',
          job_class => '''
             || i.owner_name
             || '_job_class'',
                      job_type => ''PLSQL_BLOCK'',
                      job_action => ''begin APSP.POP_TARGET(''APPS_XX'',i.owner,i.buid); end;'',
                      auto_drop => TRUE,
                      comments => '''|| i.owner_name||''',
                  enabled => TRUE);
                END;';
          EXECUTE IMMEDIATE V_SQL;
       END LOOP;
    END;
    /The procedure is having following arguments.
    CREATE OR REPLACE PROCEDURE APSP.POP_TARGET (
    p_schema_name           VARCHAR2,
       p_actual_schema_name    VARCHAR2,
       p_buid                  NUMBER
    )While executing this procedure I am getting the below error.
    PLS-00103: Encountered the symbol "APPS_XX" when expecting one of the following:
    Please help me.
    Thanks in advance .

    Try this
    create or replace procedure apsp.job_test_ram
    as
       v_sql   varchar2 (1000);
    begin
       for i
       in (select   gbm.owner_name owner_name,
                    vdb.name || '_BU_' || gbm.bu_code,
                    gbm.bu_id bu_id
             from   apps_global.GLOBAL_BU_MAPPING gbm, v$database vdb
            where   owner_name not in ('APPS_GLOBAL'))
       loop
          v_sql :=
             q'[begin
                  dbms_scheduler.create_job
                      job_name   => '#OWNER_NAME#_archive_job'
                    , job_class  => '#OWNER_NAME#_job_class'
                    , job_type   => 'STORED_PROCEDURE'
                    , job_action => q'{APSP.POP_TARGET('APPS_XX','#OWNER_NAME#','#BUILD#')}'
                    , auto_drop  => TRUE
                    , comments   => '#OWNER_NAME#'
                    , enabled    => TRUE
                end;]';
             v_sql := replace(replace(v_sql, '#OWNER_NAME#', i.owner), '#BUILD#', i.build);
          execute immediate v_sql;
       end loop;
    end;
    /

  • Error creating job into trigger using DBMS_SCHEDULER.

    Hi,
    I am trying to create job using dbms_scheduler package. I have one trigger on insert event on one table. I am creating job using following syntax.
    CREATE OR REPLACE TRIGGER TRG_BI_JOB_CONFIG BEFORE INSERT ON JOB_CONFIG FOR EACH ROW
    DECLARE
    BEGIN
         DBMS_SCHEDULER.Create_Job(job_name => 'my_job1'
                             ,job_type => 'PLSQL_BLOCK'
                             ,job_action => 'delete_temp'
                             ,start_date => TO_DATE('15-JUL-2003 1:00:00 AM', 'dd-mon-yyyy hh:mi:ss PM')
                                  ,repeat_interval => 'FREQ=DAILY'
                             ,enabled => TRUE
                             ,comments => 'DELETE FOR job schedule.');
    EXCEPTION
    WHEN OTHERS THEN RAISE;
    END;
    but I am getting following error while inserting into JOB_CONFIG table.
    ORA-04092: cannot in a trigger
    ORA-06512: at "PRAKASH1.TRG_BI_JOB_CONFIG", line 41
    ORA-04088: error during execution of trigger
    same above statement If I am running from sqlplus then It is creating job without error. If I am creating job using DBMS_JOB into trigger then It is also working fine but this package is depricated from oracle10g so I cannt use it any more.
    My Oracle version is 'Oracle DATABASE 10g RELEASE 10.2.0.1.0 - Production'.
    can anyone help me in this context.

    I have a few comments on this thread as an Oracle dbms_scheduler developer.
    - Oracle takes backward compatibility very seriously. Although dbms_job is deprecated, the interface will continue to work indefinitely. The deprecation of dbms_job is so that customers will be encouraged to take advantage of the more powerful dbms_scheduler. It is extremely unlikely that entire blocks of functionality will ever be removed. There is currently no plan to remove dbms_job functionality (and even if there were, doing so would be strenuously opposed by many users).
    - lots of internal Oracle database components are standardizing on using dbms_scheduler (resource manager, materialized views, auto sql tuning etc). This is good evidence that it will continue to be the recommended scheduling method for the foreseeable future - not even the concept of a replacement exists. It is also under active development.
    - The reason for the automatic commit is that a dbms_scheduler job is a full database object like a stored procedure or a table. So a call to dbms_scheduler.create_job is like executing a DDL which takes effect immediately. A dbms_job job is mostly just a row in a table so a call to dbms_job.submit behaves like regular DML. There are many advantages to a job being a full database object but DDL behaviour is an unfortunate requirement of this.
    Hope this clears a few things up, reply with any questions.
    -Ravi

  • STOPPED JOBS with expdp and dbms_scheduler

    Hello.
    I am working with the 10g release 2 in a RAC enviroment, and i am trying to put an export job at the scheduler.
    To launch the export i have make a shell script, then first exec the export process and after launch a bzip2 command to compress the resultant dmp file.
    The problem is that the export process finish ok, but it don't compress the file, because the scheduler mark the job as STOPPED.
    The log say:
    REASON="Stop job with force called by user: 'SYS'"
    and the expdp S.O process that launch the extjobo stay runing for ever, like if it was waiting for the expdp to exit and it can`t so the script never arrive to the part that compress the file.
    I put the script that i make to export the schema:
    #!/bin/bash
    export ORACLE_HOME=/opt/oracle/product/10.2.0/db
    export PATH=$PATH:$ORACLE_HOME/bin
    export DIRBACK=/ORACLE/BACKUPS/BMR/Dumps
    export dia=`date +%d_%m_%Y_%H_%M_%S`
    export LOG=dump_backup_bmr_$dia.log
    cd $DIRBACK
    $ORACLE_HOME/bin/expdp userid=oracle_backup/orabck@BMR dumpfile="BMR_BMR_$dia.dmp" schemas=BMR directory=Dumps logfile=$LOG
    cd $DIRBACK
    /usr/bin/bzip2 -f --best ./BMR_BMR_$dia.dmp
    cd $DIRBACK
    /bin/mail -s "DUMP BACKUP BMR DIARIO [$dia]" [email protected] < ./dump_backup_bmr_$dia.log
    I have put several cd $DIRBACK to see if it fail because the script don`t find the dmp file.
    Any idea why it STOP after finish the script ?
    PD: sorry for my poor english.
    Regards

    Hi,
    A stop is only done in two cases - if the user calls dbms_scheduler.stop_job or if the database is shutdown while a job is running. Make sure the database is not being shutdown while the job is running or inside of the job.
    If expdp is still running then this suggests that it is hanging. One possibility for that is that expdp is generating a lot of standard error messages and hanging the job (this is a known issue in 10gR2). You can try redirecting standard output and error to files to see if this helps.
    e.g.
    $ORACLE_HOME/bin/expdp > /tmp/output 2> /tmp/errors
    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.

  • Using database link via dbms_scheduler

    Hello out there,
    I have a problem calling a stored procedure via dbms_scheduler that pulls some rows over a public database link.
    The setup is the following:
    create public database link mediabase using 'mediabase';
    create or replace procedure hole_kurse as
    mdatum date;
    begin
       select max(datum) into mdatum
       from dt_wechselkurs;
       insert into dt_wechselkurs l
          (waehrung,
           datum,
           wechselkurs)
       (select
           r.waehrung,
           r.datum,
           r.wechselkurs
        from
           dt_wechselkurs@mediabase r
        where
           datum>mdatum);
        commit;
    end hole_kurse;
    begin
       dbms_scheduler.create_job(job_name          =>  'wechselkurse',
                                 job_type          =>  'STORED_PROCEDURE',
                                 job_action        =>  'hole_kurse',
                                 start_date        =>  sysdate,
                                 repeat_interval   =>  'FREQ=DAILY; BYHOUR=7; BYMINUTE=0; BYSECOND=0');
       dbms_scheduler.enable(name => 'wechselkurse');
       commit;
    end;
    /I can access the database link in SQL and I can call the procedure hole_kurse from SQL without any errors. But the job fails writing "ORA-01017: invalid username/password; logon denied" into alert.log. I also tried using dbms_job which used to work with Oracle 10g but now fails with the same error.
    My Oracle version is 11.2.0.2 64bit on Window Server 2008R2.
    So what do I have to change that my job will run?
    Many thanks in advance,
    dhalek

    I'm not completely sure, but here is a possibility:
    The [url http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_5005.htm#i2061505]docs have this to say:
    >
    If you specify CONNECT TO user IDENTIFIED BY password, then the database link connects with the specified user and password.
    If you specify CONNECT TO CURRENT_USER, then the database link connects with the user in effect based on the scope in which the link is used.
    If you omit both of those clauses, then the database link connects to the remote database as the locally connected user.
    >
    Your dblink is like this:
    create public database link mediabase using 'mediabase';That is the third case described, so the link connects as "the locally connected user", which in the scheduler session is probably not your user.
    You may try it with the second case described in the docs:
    create public database link mediabase CONNECT TO CURRENT_USER using 'mediabase';If I understand the docs correct, then within the procedure the dblink will use the schema that the procedure is owned by (unless the procedure is using invoker-rights, then it will be the invoking user.)
    It is just a guess, but you can try it and see ;-)

  • Materialized View to be run every 1 minute through dbms_scheduler

    Hi,
    I have a materialized view on 1 database which has its select statement going across a database link to numerous tables on another database.
    The materialized view creates fine and when refreshed using dbms_snapshot refreshes without error.
    My requirement is to automate this refresh for every minute. I have created a job through dbms_scheduler for the refresh to happen every minute but it fails with the error message
    ORA-12008: error in materialized view refresh path
    I have ctreated another materialized view on the database which does not go across a dblink and scheduled this though dbms_scheduler for every minute, this works fine.........
    So it appears my issue is the selecting from tables across a dblink.
    Does any one have any experience of this area, how to resolve this issue or maybe an alternative solution than dbms_scheduler?
    Thanks in advance.
    Mark.

    How is your database link defined?
    Is it using a fixed user? i.e create database link .... identified by xxxxx
    I think it needs to be to be used in a scheduled job.
    Carl

  • Dbms_Scheduler - finding out Oracle error codes / messages for failures

    Hi,
    I am using Oracle OLAP to schedule a refresh of cube data in the background and this is using the dbms_scheduler functionality, now I need to find out when and why a refresh job fails. I have found the dba_scheduler_job_log which tells me if it failed but I can't find anywhere why ?? Are the failure reasons logged anywhere ??
    Thanks in Advance,
    Brandon

    PUBLIC.DBA_SCHEDULER_JOB_RUN_DETAILS [SYNONYM]
    SYS.DBA_SCHEDULER_JOB_RUN_DETAILS [VIEW]
    The details of a job run
    Column Name                    NN? Datatype                           Comment
    LOG_ID                             NUMBER                             The unique id of the log entry. Foreign key on entry in
    LOG_DATE                           TIMESTAMP(6) WITH TIME ZONE        The date of the log entry
    OWNER                              VARCHAR2(30)                       The owner of the scheduler job
    JOB_NAME                           VARCHAR2(65)                       The name of the scheduler job
    JOB_SUBNAME                        VARCHAR2(65)                       The subname of the scheduler job (for a chain step job)
    STATUS                             VARCHAR2(30)                       The status of the job run
    ERROR# NUMBER The error number in the case of error
    REQ_START_DATE                     TIMESTAMP(6) WITH TIME ZONE        The requested start date of the job run
    ACTUAL_START_DATE                  TIMESTAMP(6) WITH TIME ZONE        The actual date the job ran
    RUN_DURATION                       INTERVAL DAY(3) TO SECOND(0)       The duration that the job ran
    INSTANCE_ID                        NUMBER                             The id of the instance on which the job ran
    SESSION_ID                         VARCHAR2(30)                       The session id of the job run
    SLAVE_PID                          VARCHAR2(30)                       The process id of the slave on which the job ran
    CPU_USED                           INTERVAL DAY(3) TO SECOND(2)       The amount of cpu used for this job run
    ADDITIONAL_INFO                    VARCHAR2(4000)                     Additional information on the job run, if applicable

  • Dbms_scheduler error in calling a schell script.

    Hi,
    I am trying to execute a shell script which is called from a procedure.
    below are the changes which i have made and after that i am still getting error as below:
    Please help me as to where i am going wrong:
    Steps takesm:
    1) rdbms/admin/externaljob.ora file to add the below info
    run_user = oracle
    run_group = dba
    2) And have changed the bin/extjob file must be permissions to 4750 (-rwsr-x---)
    3) The shell script is having full permission(777) and starts with #!/bin/ksh
    4) - bin/extjobo sfile should have normal 755 (rwxr-xr-x)
    5) - bin/jssu should have setuid permissions i.e. with 4750 (-rwsr-x---)
    error:
    ORA-27369: job of type EXECUTABLE failed with exit code: 255
    STANDARD_ERROR="execve: Exec format error"
    version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit
    DBMS_SCHEDULER.create_job (
          job_name              => 'gatekr3',
          job_type              => 'EXECUTABLE',
          job_action            => '/home/cobr_sftp/var/download/test_abh.sh',
           number_of_arguments   => 0, 
          enabled               => true,
          comments              => 'CREATE_PROGRAM test using a schell script'
    Edited by: user11942774 on Sep 27, 2012 1:22 AM

    Log to server under account oracle.
    then run /home/cobr_sftp/var/download/test_abh.sh.
    What's result of shell script ?

  • Getting error while trying to execute a external job using dbms_scheduler

    Hello,
    I create a job using alpha account.
    begin
    dbms_scheduler.create_job(
    job_name => 'jps_test_executable',
    job_type => 'EXECUTABLE',
    job_action => '/usr/bin/ksh',
    number_of_arguments => 2
    dbms_scheduler.set_job_argument_value (
    job_name => 'jps_test_executable',
    argument_position => 1,
    argument_value => '/tmp/abc.sh'
    and when I execute the job in the schema using alpha account it works fine.
    BEGIN
    DBMS_SCHEDULER.run_job (job_name => 'jps_test_executable',
    use_current_session => FALSE);
    END;
    Works fine.
    But if I try to execute the same job using some other account say beta in the same schema , I am getting error
    ORA-27476 :”SMS.RUN_SMS_JOBS Does not exist ORA-06512 at “SYS.DBMS_ISCHED” line 2793 ORA-06512 :at “SYS.DBMS_SCHEDULER”,line 1794
    even I give the fill qualifier, still I am getting the error.
    BEGIN
    DBMS_SCHEDULER.run_job (job_name => 'alpha.jps_test_executable',
    use_current_session => FALSE);
    END;
    Any help will be appreciated.
    Thank you,
    Raj

    It's the expected behavior:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#CIHHBGGI
    RUN_JOB requires that you be the owner of the job or have ALTER privileges on that job. You can also run a job if you have the CREATE ANY JOB privilege.So, you need to grant the required privilege:
    aplha@orcl> grant alter on alpha.jps_test_executable to beta;HTH
    Enrique
    PS If your problem was solved consider marking the question as answered.

  • Error while defining chain_step using dbms_scheduler.define_chain_step

    Hello,
    I am trying to create a chain_job using dbms_scheduler in <Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit>
    BEGIN
    dbms_scheduler.create_chain (
    chain_name => 'test_chain',
    rule_set_name => NULL,
    evaluation_interval => NULL,
    comments => 'Test chain.');
    END;
    -- Chain Created Successfully
    begin
    dbms_scheduler.create_program (
    program_name => 'test_program',
    program_type => 'PLSQL_BLOCK',
    program_action => 'BEGIN null; END;',
    enabled => TRUE,
    comments => 'Test program.');
    end;
    -- Program Created Successfully
    begin
    dbms_scheduler.define_chain_step (
    chain_name => 'test_chain',
    step_name => 'step_maximum_length_allowed',
    program_name => 'test_program');
    end;
    Error at line 1
    ORA-27465: invalid value STEP_MAXIMUM_LENGTH_ALLOWED for attribute step_name
    ORA-06512: at "SYS.DBMS_ISCHED", line 3912
    ORA-06512: at "SYS.DBMS_ISCHED", line 1452
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1364
    ORA-06512: at line 2
    The step_name length I used above<'step_maximum_length_allowed'> is 27 characters.
    If I use a step_name of length <= 24 characters, the define_chain_step works.
    Question:
    Does this error have to do with the maximum length allowed for step_name. If so, then the error raised should have reflected that.
    Appreciate any help.
    Thanks
    Kumar
    Edited by: 977325 on Jan 10, 2013 12:01 PM
    Edited by: 977325 on Jan 10, 2013 12:01 PM
    Edited by: 977325 on Jan 10, 2013 12:03 PM

    Thanks a lot damorgan for your reply :)
    I have gone through the link you provided. I couldn't find any limits on step naming though.
    Here is the question again with proper with proper formatting.
    I am trying to create a chain_job using dbms_scheduler in <Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit>
    BEGIN
       DBMS_SCHEDULER.create_chain (chain_name            => 'test_chain',
                                    rule_set_name         => NULL,
                                    evaluation_interval   => NULL,
                                    comments              => 'Test chain.');
    END;
    -- Chain Created Successfully
    BEGIN
       DBMS_SCHEDULER.create_program (program_name     => 'test_program',
                                      program_type     => 'PLSQL_BLOCK',
                                      program_action   => 'BEGIN null; END;',
                                      enabled          => TRUE,
                                      comments         => 'Test program.');
    END;
    -- Program Created Successfully
    <code>
    BEGIN
       DBMS_SCHEDULER.define_chain_step (
          chain_name     => 'test_chain',
          step_name      => 'step_maximum_length_allowed',
          program_name   => 'test_program');
    END;
    Error at line 1
    ORA-27465: invalid value STEP_MAXIMUM_LENGTH_ALLOWED for attribute step_name
    ORA-06512: at "SYS.DBMS_ISCHED", line 3912
    ORA-06512: at "SYS.DBMS_ISCHED", line 1452
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1364
    ORA-06512: at line 2Question:
    The step_name length I used above is 27 characters.
    If I use a step_name of length <= 24 characters, the define_chain_step works.
    Does this error have to do with the maximum length allowed for step_name. If so, then the error raised should have reflected that.

Maybe you are looking for