SQLLDR Using DBMS_SCHEDULER

hi dear
i am using sqlldr from sql with dbms_scheduler.create_job but facing some problem elow is the code
this is the schedule for my job
BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE (
schedule_name => 'INSERT_SCHD'
,start_date => sysdate
,end_date => null
     ,repeat_interval => 'FREQ=MINUTELY; INTERVAL=10'
     ,comments => 'Check for Insert Minutly schedule'
END;
below is the job
BEGIN
DBMS_SCHEDULER.Create_Job(job_name => 'Host',
               schedule_name => 'INSERT_SCHD',
job_type => 'PLSQL_BLOCK',
job_action => 'begin
               HOST (SQLLDR CRUDEOIL/CRUDEOIL10G@KHIDEV CONTROL=c:\junaid\jobs\loads.ctl log=c:\load.log);
               end;',
enabled => true);
END;
when i run this job
exec dbms_scheduler.run_job('host');
i am facing this error can some one help me out please
ERROR at line 1:
ORA-00600: internal error code, arguments: [17090], [], [], [], [], [], [], []
ORA-06512: at "SYS.DBMS_ISCHED", line 150
ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
ORA-06512: at line 1
or any other way to load data from csv file into table using dbms_scheduler please tell me the code thanks
Junaid

I have also tried with the following script , did changes as per ur suggestion. Still unable to run through scheduled job. Script is running successfully from command prompt of both "root" and "oracle" user. I have set highest Permissions of 777. Getting Error ORA -27369: job of type EXECUTABLE failed with exit code: No such file or directory
#! /bin/sh
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE=oracle
if [ $USER = "root" ]; then
su - "$ORACLE"<<EOO
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$PATH:$ORACLE_HOME/bin
cd /u01/app/oracle/product/11.2.0/db_1/bin/
sqlldr \'sys/sys as sysdba\' control=/u01/app/customer.ctl log=/u01/app/customer.log
EOO
else
sqlldr \'sys/sys as sysdba\' control=/u01/app/customer.ctl log=/u01/app/customer.log
fi

Similar Messages

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

  • 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

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

  • Using dbms_scheduler

    Hi,
    I need to run 50 sql statments simultaneously.
    I know that i can use dbms_scheduler in order to trigger all statments in the same time.
    I thought to create a procedure for each statment , and the dbms_scheduler will execute all the 50 procedures, in the very same time.
    The problem is that each statment is fairly very complex , and includs joins to
    few tables and selecting about 50-100 columns and if i want to put each statment in procedure
    than i need to assidn a variable for each column .
    Just to keep it simple , for example :
    create or replace procedure test1
    as
    v1 date;
    v2 date;
    begin
    select sysdate , sysdate + 1
    into v1,v2
    from dual;
    end;
    So actually , i am looking for a way to run the statments using dbms_scheduler , with no use of local variable.
    Is it possible (with or without procedure) ?
    Thanks

    Hi,
    Thank you for your feedback.
    I need to run 50 sql statments simultaneously, as part of POC we are planing to take soon.
    Those statments are being executing on daily basis in our DWH ETL night loading.
    The execution of the statments is managed by the ETL application tool.
    why? --> Its part of a POC we paln.
    We would like to “stretch” the system by running those statments simultaneous
    How ? -->
    I thought of having a table that store those statments , then for each statment to create a job
    as describe bellow :
    CREATE OR REPLACE PROCEDURE POC
    as
    cursor c is
    select id,name
    from poc_statments;
    Begin
    for c_rec in c loop
    BEGIN
    DBMS_SCHEDULER.create_job (
    job_name => 'POC_'||c_rec.name,
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN ?????? ; END;', <<<<=== problem is here as i expalined above
    start_date => SYSTIMESTAMP,
    enabled => true,
    auto_drop => false);
    END;
    end loop;
    end;
    This way all the statments will executed , almost , at the sime time.
    Thanks

  • Using DBMS_Scheduler Package

    Hi All,
    I am on the way to use Oracle's Scheduler component. Please guide me how to associate a job or job class with a window or window group.
    Job classes are used for prioritizing jobs and group jobs which have common resource requirements. Similarly, windows are used for automatically switching resource plans.
    Now I am confused how can I attach my jobs (and job classes) with a window.
    Is window associated with the help of schedules ?
    Thnks and Regards,
    Neeraj

    Hi.
    Using DBMS_SCHEDULER.CREATE_JOB creates the job. You can assign a schedule to the job when it is created. The inparameter schedule_name is used. When creating the window, the procedure dbms_scheduler.create_window takes some in parameters. One of these is Schedule_name. So Job is connected to a schedule and a schedule is connected to a window.
    Hopes this helps.
    rgds
    Kjell

  • Execute unix shell script using DBMS_SCHEDULER

    Hi,
    I am trying run to shell script using DBMS_SCHEDULER.
    1) I check..nobody user exist on my HP-UX.
    2) I check externaljob.ora on (10.2.0.2.0) also..It has an entry..
    run_user = nobody
    run_group = nobody
    3) I created job successfully and enabled it.
    begin
    DBMS_SCHEDULER.CREATE_JOB
    job_name => 'test_unix_script',
    job_type => 'EXECUTABLE',
    job_action => '/tmp/test.ksh',
    start_date => '08-NOV-2006 04:45:16 PM',
    job_class => 'DEFAULT_JOB_CLASS',
    enabled => TRUE,
    auto_drop => FALSE,
    comments => 'test_unix_script.'
    END;
    EXEC DBMS_SCHEDULER.enable('test_unix_script');
    4) test.ksh script had -r-xr-xr-x permission.
    5) When I checking dba_scheduler_job_run_details view, ADDITIONAL_INFO column display following error messgae.
    ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
    Did I miss anything?
    Any help will be appreciated!!
    Thanks..

    My /tmp/test.ksh trying to find database status.
    . ~oracle/.profile > /dev/null
    db_status=`eval sqlplus -s 'system/passwd@DEV' << EOF
    set pagesize 0 feedback off verify off heading off echo off
    select status from v\\$instance;
    exit
    EOF`
    echo $db_status > /tmp/db_status_out

  • Scheduling an sql script using dbms_scheduler

    Hi Experts,
    I am having an oracle 10g database on windows platform. I have an sql script which has a normal set of sql statements (insertion and updation).
    I would like to schedule to run this sql script using dbms_scheduler but I've gone through certain sites and came to know that it's not possible to schedule an sql script using dbms_scheduler. Please let me know how I can schedule this script using dbms_scheduler.

    It is possible - in 10g and above you can use DBMS_SCHEDULER to call an external procedure, which in this case could be a call to your SQL file.
    Get's a bit more complicated with older versions, but still doable.
    But - unless there is a really good reason why you cannot do so, move this into a PL/SQL procedure as suggested.
    Carl

  • Building pages to use dbms_scheduler like in OEM, is it a good idea?

    In OEM, there's already full featured web pages to administrate scheduler objects, sometimes, OEM is very heavy in load, during my first testing, it even make my db server hang, run out of swap. But I try to build a simple page to submit jobs using dbms_scheduler, it works file and quite light weighted.
    So is it a good idea to build scheduler administration pages in Apex? will it be like reinvent a wheel?

    This is what I am trying to do but have run into the 'insufficient privileges' problem. I am actually trying to give our users the ability to schedule some of the jobs associated with their application. I've been able to submit a job through Toad under the schema used by the application. But I'm not sure whether I need to grant the appropriate privileges to run the scheduler package to the flows schema as well. I have also been able to schedule the job through the SQL Workshop in the APEX application builder, but I can't do it through the application. Any suggestions?
    Sue
    Edited by: suewia on Jan 6, 2010 7:14 AM

  • How to run the job using DBMS_SCHEDULER

    How to run the job using DBMS_SCHEDULER
    pleas give some sample Iam very new to DBMS_SCHEDULER

    Hi
    DBMS_SCHEDULER
    In Oracle 10g the DBMS_JOB package is replaced by the DBMS_SCHEDULER package. The DBMS_JOB package is now depricated and in Oracle 10g it's only provided for backward compatibility. From Oracle 10g the DBMS_JOB package should not be used any more, because is could not exist in a future version of Oracle.
    With DBMS_SCHEDULER Oracle procedures and functions can be executed. Also binary and shell-scripts can be scheduled.
    Rights
    If you have DBA rights you can do all the scheduling. For administering job scheduling you need the privileges belonging to the SCHEDULER_ADMIN role. To create and run jobs in your own schedule you need the 'CREATE JOB' privilege.
    With DBMS_JOB you needed to set an initialization parameter to start a job coordinator background process. With Oracle 10g DBMS_SCHEDULER this is not needed any more.
    If you want to user resource plans and/or consumer groups you need to set a system parameter:
    ALTER SYSTEM SET RESOURCE_LIMIT = TRUE;
    Baisc Parts: Job
    A job instructs the scheduler to run a specific program at a specific time on a specific date.
    Programs
    A program contains the code (or reference to the code ) that needs to be run to accomplish a task. It also contains parameters that should be passed to the program at runtime. And it?s an independent object that can referenced by many jobs
    Schedules
    A schedule contains a start date, an optional end date, and repeat interval with these elements; an execution schedule can be calculated.
    Windows
    A window identifies a recurring block of time during which a specific resource plan should be enabled to govern resource allocation for the database.
    Job groups
    A job group is a logical method of classifying jobs with similar characteristics.
    Window groups
    A window groups is a logical method of grouping windows. They simplify the management of windows by allowing the members of the group to be manipulated as one object. Unlike job groups, window groups don?t set default characteristics for windows that belong to the group.
    Using Job Scheduler
    SQL> drop table emp;
    SQL> Create table emp (eno int, esal int);
    SQL > begin
    dbms_scheduler.create_job (
    job_name => 'test_abc',
    job_type => 'PLSQL_BLOCK',
    job_action => 'update emp set esal=esal*10 ;',
    start_date => SYSDATE,
    repeat_interval => 'FREQ=DAILY; INTERVAL=10',
    comments => 'Iam tesing scheduler');
    end;
    PL/SQL procedure successfully completed.
    Verification
    To verify that job was created, the DBA | ALL | USER_SCHEDULER_JOBS view can be queried.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_abc FALSE 0
    Note :
    As you can see from the results, the job was indeed created, but is not enabled because the ENABLE attribute was not explicitly set in the CREATE_JOB procedure.
    Run your job
    SQL> begin
    2 dbms_scheduler.run_job('TEST_abc',TRUE);
    3* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_ABC FALSE 0
    Copying Jobs
    SQL> begin
    2 dbms_scheduler.copy_job('TEST_ABC','NEW_TEST_ABC');
    3 END;
    4 /
    PL/SQL procedure successfully completed. Hope it will help you upto some level..!!
    Regards
    K

  • Need help using dbms_scheduler to submit an immediate job on the database

    Hi. I need help using dbms_scheduler to submit an immediate job on the database. Essentially I want to issue a one-time call to an Oracle Stored Procedure - this procedure will then send an email. I've never used dbms_scheduler before, but here's what I have so far.
    So my Program is a stored database procedure named 'TTMS.dropperVacationConflict_Notify', but my problem is that I need to pass 3 parameter values to this job each time I run it. This is what I can't figure out. The procedure expects an 'Id' as number(5), begin_dt as a date, and end_dt as a date.
    How do I pass these values when I run my job? Can anyone help?
    begin
        dbms_scheduler.create_program(program_name=> 'PROG_DROPVACCONFLICTS_NOTIFY',
         program_type=> 'STORED_PROCEDURE',
         program_action=> 'TTMS.dropperVacationConflict_Notify',
         number_of_arguments => 3,
         enabled=>true,
         comments=> 'Procedure to notify PCM of a Dropper Vacation Conflict. Pass in Dropper Id, Begin_dt, and End_dt');
    end;
    begin
        dbms_scheduler.create_schedule
        (schedule_name=> 'INTERVAL_EVERY5_MINUTES',
         start_date=> trunc(sysdate)+18/24,
         repeat_interval => 'freq=MINUTELY;interval=5',
         end_date => null
         comments=> 'Runtime: Every day all 5 minutes, forever'
    end;
    begin
        dbms_scheduler.create_job
        (job_name => 'JOB_DROPVACCONFLICTS_NOTIFY',
         program_name => 'PROG_DROPVACCONFLICTS_NOTIFY',
         schedule_name => 'INTERVAL_EVERY5_MINUTES',
         enabled => true,
         auto_drop => true,
         comments => 'Job to notify PCM of Dropper Vacation Conflicts'
    end;
    /And I use this to execute the job as needed...
    begin
        dbms_scheduler.run_job('JOB_DROPVACCONFLICTS_NOTIFY',true);
    end;
    /

    Duplicate Post
    Need help using dbms_scheduler to submit an immediate job on the database

  • Issue with calling Shell Script using DBMS_SCHEDULER

    Hi All,
    I am executing a shell script using DBMS_SCHEDULER from APEX web page. Execution part is working fine without any issues.
    In my shell script file (abc.sh) I have few oracle sql procedure calls which connects back to same database and that SQL call is not executing some reason, it not giving any errors.
    Inside my shell script code looks like this.
    sqlplus -silent $USER/$PASSCODE@$SCONNECT > /dev/null <<END
    set pagesize 0 feedback off verify off heading off serveroutput on
    echo off linesize 1000
    WHENEVER SQLERROR EXIT 9
    BEGIN     
    dbms_output.enable(1000000);
    do_enable_cons();
    dbms_output.disable;
    END;
    spool off;
    exit;
    END
    When I run this shell script file from backend it works fine now issues.
    Is there any restrictions in executing sql code using DBMS_SCHEDULER? Any ones help is much appreciated.
    -Regards

    james. wrote:
    Thanks you sb and Sybrand . It is problem with environment variables. After running .bash_profile in the beginning of the shell script, it is working fine.
    One issue is when I check the process it is showing two entries with two different process id's.
    The command I used
    ps -ef | grep <my script> is COPY & PASTE broken for you?
    any reason why you did not show us EXACTLY was produced by OS command above?
    >
    Is it something wrong with my code or is it normal? Is it really executing two times ?
    -Regards
    bcm@bcm-laptop:~$ sqlplus user1/user1
    SQL*Plus: Release 11.2.0.1.0 Production on Fri Jul 20 15:14:15 2012
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    15:14:15 SQL> !ps -ef | grep sqlplus
    bcm      24577  1903  1 15:14 pts/0    00:00:00 sqlplus           
    bcm      24579 24577  0 15:14 pts/0    00:00:00 /bin/bash -c ps -ef | grep sqlplus
    bcm      24581 24579  0 15:14 pts/0    00:00:00 grep sqlplus
    15:14:23 SQL> how many different copies of "sqlplus" running on my laptop based upon actual output above?

  • How read shell log file using DBMS_SCHEDULER

    Hi All,
    I am running a shell script file using DBMS_SCHEDULER and it creates couple of log file. I am trying to run other DBMS_SCHEDULER job2 to read current log file written by job1 display on APEX web page. I am using oracle 10g version. Any suggestions are much appreciated.
    Regards

    james. wrote:
    Thank you Purvesh K. I want to read the log file as soon as I started the my shell script.
    " Just call the Stored program to read the files "
    Can you give me an example of the stored program you mentioned?
    RegardsOracle UTL_File contains example of reading from a UTL_File. (Just in case you are not aware of doing so.)
    What I intended to say was:
    1. You might be having a Job Scheduled/Calling a stored program to create a Log File.
    2. You can directly call the Stored Program (Function/Procedure) that contains the logic to Read the Log File.

  • Errors using dbms_scheduler instead of dbms_job

    Hello,
    I'm looking for some help using the dbms_scheduler in Oracle 10g. Up until recently, we have been happily submitting jobs in Oracle using the dbms_job.submit() command without problems. Due to this now becoming deprecated in release 10g and beyond we are looking to make use of the new dbms_scheduler.create_job() functionality. However, when trying to convert from dbms_job to dbms_scheduler, I keep getting errors when trying to run the stored procedure. I'm sure I must be missing something obvious but I just cannot put my finger on it at present.
    The set up using dbms_job is as follows:
    We have a procedure (called PRODCEURE_A) that is called directly from our code and included in the procedure is a call to dbms_job that submit a job to run PROCEDURE_C which in turn calls a PROCEDURE_B. For example PRODCEURE_A is created as follows:
    create or replace procedure PRODCEURE_A AS
    jobnum number;
    row_count number;
    current_value_date DATE;
    snapshot_id Number;
    BEGIN
    row_count :=0;
         BEGIN
              /* Fetch current value date and snapshot number */
              SELECT COL_A, (COL_A- COL_B)
              INTO current_value_date, snapshot_id
              FROM TABLE_A
              WHERE COL_C= 0;
              /* delete records from TABLE_A table that are older than 40 days */
              DELETE TABLE_A WHERE COL_A < current_value_date - 40;
              /* ensure that are no records in TABLE_A for the current settlement date */
              select count(*) into row_count
              from TABLE_A
              where COL_A = current_value_date;
              /* Insert all the Date snapshot jobs into TABLE_Awith initial status as NS */
              if row_count < 1 then
              Begin
                   insert into TABLE_A values (1, 'PROCEDURE_B', current_value_date, NULL, NULL, 'NS', NULL);
                   /* Submit the oracle job spst_execute_date_snapshot to run asynchronously */
                   dbms_job.submit(jobnum, 'PROCEDURE_C ('||''''||current_value_date||''''||', ' || snapshot_id || ');');
              End;
              END IF;
         END;
    END;
    This works without problems. A job is created and PROCEDURE_C is duly executed. I attempt to change dbms_job to dbms_scheduler as below:
    create or replace procedure PRODCEURE_A AS
    jobnum number;
    row_count number;
    current_value_date DATE;
    snapshot_id Number;
    BEGIN
    row_count :=0;
         BEGIN
              /* Fetch current value date and snapshot number */
              SELECT COL_A, (COL_A- COL_B)
              INTO current_value_date, snapshot_id
              FROM TABLE_A
              WHERE COL_C= 0;
              /* delete records from TABLE_A table that are older than 40 days */
              DELETE TABLE_A WHERE COL_A < current_value_date - 40;
              /* ensure that are no records in TABLE_A for the current settlement date */
              select count(*) into row_count
              from TABLE_A
              where COL_A = current_value_date;
              /* Insert all the Date snapshot jobs into TABLE_A with initial status as NS */
              if row_count < 1 then
              Begin
                   insert into TABLE_A values (1, 'PRODCEURE_B', current_value_date, NULL, NULL, 'NS', NULL);
                   /* Submit the oracle job spst_execute_date_snapshot to run asynchronously */
              dbms_scheduler.create_job(
    job_name => '"JOB_NAME"',
    job_type => 'STORED_PROCEDURE',
    job_action => 'PRODCEURE_C('||''''||current_value_date||''''||', ' || snapshot_id || ');',
    enabled => TRUE);
              End;
              END IF;
         END;
    END;
    However, when trying the above I get the following error:
    ORA-27452: PROCEDURE_C('22-JUL-09', 2494); is an invalid name for a database object
    When I attempt to change job_type from 'STORED_PROCEDURE' to PLSQL_BLOCK as follows:
    create or replace procedure PRODCEURE_A AS
    jobnum number;
    row_count number;
    current_value_date DATE;
    snapshot_id Number;
    BEGIN
    row_count :=0;
         BEGIN
              /* Fetch current value date and snapshot number */
              SELECT COL_A, (COL_A- COL_B)
              INTO current_value_date, snapshot_id
              FROM TABLE_A
              WHERE COL_C= 0;
              /* delete records from TABLE_A table that are older than 40 days */
              DELETE TABLE_A WHERE COL_A < current_value_date - 40;
              /* ensure that are no records in TABLE_A for the current settlement date */
              select count(*) into row_count
              from TABLE_A
              where COL_A = current_value_date;
              /* Insert all the Date snapshot jobs into TABLE_A with initial status as NS */
              if row_count < 1 then
              Begin
                   insert into TABLE_A values (1, 'PRODCEURE_B', current_value_date, NULL, NULL, 'NS', NULL);
                   /* Submit the oracle job spst_execute_date_snapshot to run asynchronously */
              dbms_scheduler.create_job(
    job_name => '"JOB_NAME"',
    job_type => PLSQL_BLOCK',
    job_action => 'BEGIN PRODCEURE_C('||''''||current_value_date||''''||', ' || snapshot_id || '); END;',
    enabled => TRUE);
              End;
              END IF;
         END;
    END;
    This gives the following error:
    ORA-02089: COMMIT is not allowed in a subordinate session
    I'm stumped by both of these errors. Firstly, why should I get an error reported that the PROCEDURE_C is an invalid name? It lives in the user's schema that is running PROCEDURE_A (and so submitting the scheduled job?)
    Secondly, why the COMMIT error when running as a PLSQL_BLOCK? I can't see any commit is used within the procedure itself.
    Any help would be welcomed. If more info required, please let me know.
    Thank you.

    One question.
    Are you aware that DBMS_SCHEDULER will do a commit for you?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:25405608521707
    umm, dbms_job does not commit.
    A job when run will have it's transaction ended. That is expoected, normal, correct.
    But when you CALL dbms_job - to submit a job - dbms_job.submit DOES NOT COMMIT.
    So, no, dbms_job does not commit.
    So that would break your existing transaction (if you replaced dbms_job with dbms_scheduler). If you're ok with that then your issue is still pertinent, if not, then it's obviated by you not being able to use dbms_scheduler :D)

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

Maybe you are looking for

  • How can I see what drive the music I download is going to?

    How can I see where the music I download and put in Itunes is being stored in?

  • Elements 11 - Brush tool not working when using layer mask

    My brush tool won't work when using layer mask in PS Elements 11. I also have Elements version 10 installed and there it works fine. If I do the exact same proces in version 11 nothing happens. Is this a bug or has something changed in the proces? Pl

  • Rotated IXUS images download by PSA SE  not rotated

    I have just started using Photoshop Album Starter Edition for downloading images from my Canon DIGITAL IXUS 400, and I experience a problem. The camera has a sensor for the rotation of the camera when the image was taken, and this information follows

  • Moving Feed but Can't access current Feed?

    Hi. I'm looking for some help/advice. I just started a video screen/podcast. The iTunes link is here: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=323522943 I used screencast.com has my hosting/feed provider for this podcast. Now

  • Streaming apple lossless

    I have an Airport Extreme base station, 2 years old (n), with three Airport Expresses of the same vintage. Can this system stream Apple Lossless format or do I need a Sonos system to get the better quality?