1 2 Previous Next 18 Replies Latest reply on Mar 7, 2013 1:56 AM by sb92075 Go to original post
      • 15. Re: Creating job, ran successfuly, but not seen on dba_scheduler_jobs
        555329
        Hello, I used another approach to resolve the issuer and it worked fine. See the following:

        Contents of cp.cmd= cp c:\temp\sqlnet.log c:\temp\temp\


        user to be used: sys
        ===============


        1. create a programme that will execute the command.
        ---------------------------------------------------

        BEGIN
        DBMS_SCHEDULER.CREATE_PROGRAM
        (
        PROGRAM_NAME => 'PROGRAM_RULES_SERVICES',
        PROGRAM_TYPE => 'EXECUTABLE',
        PROGRAM_ACTION => 'c:\temp\cp.cmd',
        NUMBER_OF_ARGUMENTS => 0,
        COMMENTS => 'START RULE SERVICES AFTER DATABASE STARTUP'
        );
        END;
        /


        2. create a job to launch the program.
        --------------------------------------

        BEGIN
        DBMS_SCHEDULER.CREATE_JOB
        (
        JOB_NAME => 'JOB_RULES_SERVICES',
        PROGRAM_NAME => 'PROGRAM_RULES_SERVICES',
        AUTO_DROP => FALSE,
        COMMENTS => 'TO START RULES SERVICES'
        );
        END;


        3. enable job and program
        -------------------------

        BEGIN
        DBMS_SCHEDULER.ENABLE ('PROGRAM_RULES_SERVICES');
        END;

        BEGIN
        DBMS_SCHEDULER.ENABLE ('JOB_RULES_SERVICES');
        END;


        4. MANUAL running the job: only for test purpose
        ------------------------------------------------

        BEGIN
        DBMS_SCHEDULER.RUN_JOB('JOB_RULES_SERVICES',TRUE);
        END;


        *************
        Verifications
        *************

        1. verify that the job ran successfuly
        ---------------------------------------
        col status for a20 wrap
        col session_id 9999999
        col run_duration for a20 wrap
        col additional_info for a20 wrap
        col ERROR# for 99999999
        col job_name for a20 wrap
        set lines 400

        select job_name,status,run_duration,session_id, ERROR#,additional_info from dba_SCHEDULER_JOB_RUN_DETAILS where job_name='JOB_RULES_SERVICES';


        JOB_NAME STATUS RUN_DURATION SESSION_ID ERROR# ADDITIONAL_INFO
        -------------------- -------------------- -------------------- ------------------------------ --------- --------------------
        JOB_RULES_SERVICES SUCCEEDED +000 00:00:00 159,1 0
        JOB_RULES_SERVICES SUCCEEDED +000 00:00:00 159,1

        Thanks you very much for your help.
        • 16. Re: Creating job, ran successfuly, but not seen on dba_scheduler_jobs
          Rnr-Oracle
          Hi,

          For external jobs on Windows, you need to configure and enable the Oracle Scheduler Windows service by going to the Services administration panel.

          For more help on running external jobs check this post

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

          Hope this helps,
          Ravi.
          • 17. Re: Creating job, ran successfuly, but not seen on dba_scheduler_jobs
            user1066901
            I tested this this on Windows 7 Ultimate Oracle 11g R2:
            If you have one statement line in bat file, this will work. Each element in your bat file should be represented with an argument value.
            Argument 5 and 6 should be replaced with some file you have on your system for testing.
            Example of bat: zip -j -q c:\temp\file.zip c:\temp\file.pdf

            BEGIN
            DBMS_SCHEDULER.create_job(
            job_name => 'zipfiles',
            job_type => 'EXECUTABLE',
            job_action => 'c:\windows\system32\cmd.exe',
            number_of_arguments => 6,
            enabled => FALSE, -- will not start without being enabled
            auto_drop => TRUE); -- will drop from scheduler once completed
            END;
            /

            exec DBMS_SCHEDULER.set_job_argument_value(job_name => 'zipfiles', argument_position => 1, argument_value => '/c'); --Carries out the command (cmd.exe) specified by string and then terminates.
            exec DBMS_SCHEDULER.set_job_argument_value(job_name => 'zipfiles', argument_position => 2, argument_value => 'zip'); --Zip command
            exec DBMS_SCHEDULER.set_job_argument_value(job_name => 'zipfiles', argument_position => 3, argument_value => '-j'); --Drops directory information
            exec DBMS_SCHEDULER.set_job_argument_value(job_name => 'zipfiles', argument_position => 4, argument_value => '-q'); --Runs in quiet mode
            exec DBMS_SCHEDULER.set_job_argument_value(job_name => 'zipfiles', argument_position => 5, argument_value => 'c:\temp\file.zip'); --zip file name
            exec DBMS_SCHEDULER.set_job_argument_value(job_name => 'zipfiles', argument_position => 6, argument_value => 'c:\temp\file.pdf'); --file name to zip
            exec DBMS_SCHEDULER.enable('zipfiles'); -- start the job

            Make sure scheduler is running. Must manually start unless you change your service options to automatically start.
            Check grant permissions - grants to create:
            GRANT CREATE JOB TO whomever;
            GRANT CREATE ANY JOB TO whomever;

            Edited by: user1066901 on Mar 6, 2013 5:49 PM

            Edited by: user1066901 on Mar 6, 2013 5:51 PM
            • 18. Re: Creating job, ran successfuly, but not seen on dba_scheduler_jobs
              sb92075
              user1066901 wrote:
              I tested this this on Windows 7 Ultimate Oracle 11g R2:
              please limit your responses to threads that are less than a few days old as opposed to 4 YEARS
              1 2 Previous Next