7 Replies Latest reply: Oct 19, 2012 4:11 AM by 896548 RSS

    what is wrong? dbms_scheduler

    896548
      Hi
      I apologize that I am repeating the question but this is important to me and I am trying solve that from a few days
      Oracle XE 11g, Windows XP I can make backup by Windows schedule tasks, I need to do the same operation by dbms_scheduler, pls look my below scripts and inform me where is mistake thank you in advance

      daily.bat
      rman target / catalog rman/rman@XE @D:\Oracle\Script\daily_backup.txt
      daily_backup.txt
      RUN {
            ALLOCATE CHANNEL ch1 TYPE 
              DISK FORMAT 'D:\Oracle\Backup\ic_13_%D%M%Y'; 
            BACKUP INCREMENTAL LEVEL 1 DATABASE PLUS ARCHIVELOG;
            RELEASE CHANNEL ch1;
          }
          EXIT;
      I created credential_name 'KRZYSZTOF', and below script for Oracle scheduler
      BEGIN
        DBMS_SCHEDULER.create_job(
          job_name             => 'Inc1',
          job_type             => 'EXECUTABLE',
          number_of_arguments  => 3,
          job_action           => 'C:\windows\system32\cmd.exe',
          credential_name   => 'KRZYSZTOF'
          auto_drop            => FALSE,
          enabled              => FALSE);
      
        DBMS_SCHEDULER.set_job_argument_value('Inc1',1,'/q');
        DBMS_SCHEDULER.set_job_argument_value('Inc1',2,'/c');
        DBMS_SCHEDULER.set_job_argument_value('Inc1',3,'D:\Oracle\Script\daily.bat');
        DBMS_SCHEDULER.enable('Inc1');
      END;
      /
      after execute I got

      ORA-27370: job slave failed to launch a job of type EXECUTABLE
      ORA-27300: OS system dependent operation:accessing login executable failed with status: 2
      ORA-27301: OS failure message: cannot find the file specified
      ORA-27302: failure occurred at: sjsecl 1
      ORA-27303: additional information: cannot find the file specified.
      ORA-06512: at "SYS.DBMS_ISCHED", line 185
      ORA-06512: at "SYS.DBMS_SCHEDULER", line 486
      ORA-06512: at line 1
      27370. 00000 - "job slave failed to launch a job of type EXECUTABLE"
      *Cause:    The scheduler ran into an error when the job slave tried to start
      a job of type EXECUTABLE. The rest of the error stack will provide
      more detailed information on what the exact problem was.
      *Action:   Correct the problem specified in the error stack and reschedule
      the job.

      I'm using Oracle SQL Developer for enter above script.
        • 1. Re: what is wrong? dbms_scheduler
          odie_63
          Did you start the OracleJobSchedulerXE service?
          • 2. Re: what is wrong? dbms_scheduler
            896548
            yes
            • 3. Re: what is wrong? dbms_scheduler
              rp0428
              >
              Oracle XE 11g, Windows XP I can make backup by Windows schedule tasks, I need to do the same operation by dbms_scheduler
              >
              The first step is to confirm that you can run a windows executable properly. Try this Oracle-base example and confirm that it runs properly.
              http://www.oracle-base.com/articles/11g/scheduler-enhancements-11gr1.php

              Pay particular attention to this comment
              >
              Windows commands and scripts must be run using the "cmd.exe" executable with the first parameter of "/c". To perform an action similar to the previous example, we would need to use three parameters.
              >
              In your example you are passing /c as the second parameter. Do this example work for you?
              BEGIN
                -- Windows
                DBMS_SCHEDULER.create_job(
                  job_name             => 'win_command_job',
                  job_type             => 'EXECUTABLE',
                  number_of_arguments  => 3,
                  job_action           => 'C:\windows\system32\cmd.exe',
                  auto_drop            => FALSE,
                  enabled              => FALSE);
              
                DBMS_SCHEDULER.set_job_argument_value('win_command_job',1,'/c');
                DBMS_SCHEDULER.set_job_argument_value('win_command_job',2,'dir');
                DBMS_SCHEDULER.set_job_argument_value('win_command_job',3,'C:\');
              
                DBMS_SCHEDULER.set_attribute('win_command_job', 'credential_name', 'TIM_HALL_WIN_CREDENTIAL');
                DBMS_SCHEDULER.set_attribute('win_command_job', 'destination', 'marge.localdomain:65001');
                DBMS_SCHEDULER.enable('win_command_job');
              END;
              /
              • 4. Re: what is wrong? dbms_scheduler
                896548
                Good morning RP

                Thank you for Yr reply.

                >
                The first step is to confirm that you can run a windows executable properly. Try this Oracle-base example and confirm that it runs properly.
                http://www.oracle-base.com/articles/11g/scheduler-enhancements-11gr1.php
                >

                I based on this example, except Oracle Scheduler Agent Installation. I think Scheduler Agent isn't needed. Am I right?


                >
                In your example you are passing /c as the second parameter. Do this example work for you?
                >

                hmm .... I don't know what I should write, I tested:
                BEGIN
                  -- Windows
                  DBMS_SCHEDULER.create_job(
                    job_name             => 'win_command_job',
                    job_type             => 'EXECUTABLE',
                    job_action           => 'C:\windows\system32\cmd.exe /c @D:\path to bat file',
                   credential_name     => 'KRZYSZTOF' and without credential_name 
                    auto_drop            => FALSE,
                    enabled              => FALSE);
                END;
                / 
                /c as second parameter. I don't think it will be help (see above).
                • 5. Re: what is wrong? dbms_scheduler
                  rp0428
                  >
                  I based on this example, except Oracle Scheduler Agent Installation. I think Scheduler Agent isn't needed. Am I right?
                  >
                  The agent is used when you want to run a remote job.

                  I posted the excerpted article code in my reply but it doesn't look like you tried it.

                  Reread my reply and try the code I posted and then post the results.
                  • 6. Re: what is wrong? dbms_scheduler
                    896548
                    unfortunately, I got the same messages
                    thank you for yr replies
                    regards
                    • 7. Re: what is wrong? dbms_scheduler
                      896548
                      As you know I tired some time with above rman script to oracle schduler. After a few days testing and reading a houndreds toturials I just have found solution

                      problem was in daily.bat file, which should contains:
                      C:\oraclexe\app\oracle\product....\bin\rman target sys/password@XE catalog rman/rman@XE @D:\Oracle\Script\daily_backup.txt log=yr path to log file 
                      and sql script to schduler:
                      BEGIN
                        DBMS_SCHEDULER.create_job(
                          job_name             => 'Inc1',
                          job_type             => 'EXECUTABLE',
                          number_of_arguments  => 2,
                          job_action           => 'C:\windows\system32\cmd.exe',
                          auto_drop            => FALSE,
                          enabled              => FALSE);
                       
                         DBMS_SCHEDULER.set_job_argument_value('Inc1',1,'/c');
                        DBMS_SCHEDULER.set_job_argument_value('Inc1',2,'D:\Oracle\Script\daily.bat');
                        DBMS_SCHEDULER.enable('Inc1');
                      END;
                      / 
                      Execute of above works ok. I hope that some that will be help for somebody.

                      Regards