Job with DBMS_JOB

Hi ,
I have created a job as below, i have to refresh the materialized view on 21st of every month at 9pm. please see the below code, advice if i am wrong.
DECLARE
v_JobNum  NUMBER;
BEGIN
DBMS_JOB.SUBMIT(v_JobNum   ,
'DBMS_MVIEW.REFRESH(''ABC_RUN'');',
SYSDATE, 'to_date(21 || to_char(sysdate, ''mmrrrr''), ''dd-mm-rrrr'')+21/24');
END;Thanks

Hi
see
dbms_job.submit job twice a month on particular days
Best regards,
Nikolay

Similar Messages

  • Problems with DBMS_JOB - not running jobs

    Hello,
    for some reason our Database (after night restart - shutdown at 23:00, startup at 0:20) stopped to run jobs from DBMS_JOB. I've enabled them manually (DBMS_JOB.RUN(2334)) - but they still not run after reaching the NEXT_DATE,NEXT_SEC time.
    I've noticed that:
    select * from dba_scheduler_global_attribute where ATTRIBUTE_NAME='CURRENT_OPEN_WINDOW';
    ATTRIBUTE_NAME VALUE
    CURRENT_OPEN_WINDOW TUESDAY_WINDOW
    Current day of week is wednesday not tuesday - and I think that is the reason.
    I've tried this statement:
    SQL> execute DBMS_SCHEDULER.CLOSE_WINDOW(WINDOW_NAME => 'TUESDAY_WINDOW');
    BEGIN DBMS_SCHEDULER.CLOSE_WINDOW(WINDOW_NAME => 'TUESDAY_WINDOW'); END;
    ERROR at line 1:
    ORA-00449: background process '' unexpectedly terminated with error
    ORA-06512: at "SYS.DBMS_ISCHED", line 347
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 968
    ORA-06512: at line 1
    Is there any other way to fix this problem without restart of database?
    Thank you for any help
    Best regards

    Manually execute the job and let it run itself beginning next Tuesday.

  • Schedule a job using dbms_job package

    SQL to schedule a job using DBMS_JOB.
    variable jobno number;
    variable status number;
    begin
    dbms_job.submit(:jobno, 'x(:status);', trunc(sysdate)+8/24,
    'trunc(sysdate)+1+8/24', null);
    commit;
    end;
    It fails and returns the following error ...
    ORA-01008: not all variables bound
    Is it possible to schedule a job to run a procedure with "IN OUT" parameter? I would appreciate any assistance.
    Proc runs if I execute it from command mode and there are no issues.

    You cannot pass parameters back from a job-- Oracle spawns a separate session to run your job, so that session would receive any OUT parameters and end immediately after the job finishes. Even if Oracle let you do this, you would lose the OUT value as soon as the job ended.
    If you want a job to return a status, you can-
    1) Store the status in a table
    2) Queue a status message in an Oracle Advanced Queue
    3) Use dbms_alert to alert another process
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Schedule a job in dbms_job which should run first of every month at 14:00.

    Hi Gurus,
    I want to schedule a job in dbms_job which should run on first of every month at 14:00.
    Job will execute a stored procedure.
    With Regards,
    Gopal.

    gopal wrote:
    Hi Aman,
    My DB version is 10g but it was migrated from 9i fews weeks back.I'm aware that dbms_scheduler is very easy to use.I tried to use dbms_scheduler but the stored procedure which the job executing uses user_jobs and dba_jobs in the script to do some tasks.So, I have to use dbms_job option.
    Just as an FYI for future posts ... that could have been very useful information to know up front. It's very difficult to give good advice when someone sets seemingly arbitrary restrictions on what constitutes an acceptable solution (must use dba_jobs) with no explanation of the reason for said restrictions.
    I used trunc(LAST_DATE(SYSDATE) +1)+14/24 to schedule the job.
    Thanks Aman.. I follow your blog :)

  • OWB map with DBMS_JOBS.SUBMIT

    We use DBMS_JOB package to kick our OWB maps.Previously it worked very fine ..But from near about 2 weeks we are facing problems.
    Problem is though our JOB_QUEUE_PROCESS is set to 8 and even I can see 8 jobs with this_data populated in dba_jobs (means jobs are running as we cannot query DBA_JOBS_RUNNING view to see the no of jobs running as it is taking too much time ) we can see only entry of two of there maps in WB_RT_AUDIT.other maps start only if these two get complete .
    and there is huge time difference between actual job start time and the entry into WB_RT_AUDIT table .
    can any one help us with solution.
    Bcos of this issues load which used to take max 4 hours is now taking 24 hours..
    Thanks & Regards

    Please any to help this situation..

  • Problem with DBMS_JOB

    Hi I've created a job with the following block:
    DECLARE
    wprogname varchar2(100);
    start_date date;
    winterval varchar2(100);
    wjobno NUMBER;
    BEGIN
    wprogname := 'GSA.JOB_TEST2;';
    start_date := SYSDATE;
    winterval := 'SYSDATE+2/1440';
    DBMS_JOB.SUBMIT(wjobno, wprogname, start_date , winterval,false,1,true);
    COMMIT;
    END;
    This should be running for every 2 minutes. But it is running for every 45 mins to 1 hr or so.... Could some one suggest me a solution for this. I need to run this job for every 2 mins.....Last time it ran at 2:28 PM and the next_date shows is 2:30 PM. But the job ran at 3:30. Now the next_date shows as 3:32 PM, but it didn't ran at that time. Please suggest.

    Hi!
    Pls check the following code --
    VARIABLE jobno number;
    BEGIN
       DBMS_JOB.SUBMIT(job => :jobno,
                       what => 'begin p1; end;',
                       next_date => SYSDATE,
                       interval => 'SYSDATE + 2/1440');
       commit;
    END;
    PL/SQL procedure successfully completed.
    SQL> print jobno;
         JOBNO
            81Regards.
    Satyaki De.
    Message was edited by:
    Satyaki_De

  • Jobs with a startevent and starttime

    hello,
    I'd like to plan a job in an abap program which is started when an event is raised or a certain timespan
    has passed.
    When planing the job by using the functionmodules job_open, job_submit and and job_close I can supply an event and a startdate but the implementation of the functionmodules ignores the event when the startdate parameter is supplied.
    Is there a workaround to enable event triggered jobs with a startdate which is used if the event is not raised within a certain timespan or do I really hav to use 2 jobs?
    thanks
    Roman

    Hello Roman
    I think you have to use 2 jobs, but if you use 2 jobs with the same program the program may run twice.
    You could create 1 job with your program that is started by event and 1 job with a startdate/time that runs a program that raise the event.
    best regards
    Thomas Madsen Nielsen

  • Schedule Job with Job_close after successful job doesn't work

    Hi guys,
    I'm using FM CLOSE_JOB with parameters : 
                JOBCOUNT             = w_JobId
                JOBNAME              = w_JobName
                PREDJOB_CHECKSTAT    = 'X'
                PRED_JOBCOUNT        = w_oldJobId
                PRED_JOBNAME         = w_oldJobName
    I have about 9 jobs wich must run the one after the others. The first start without PRED* parameters, but the 8 others one are filled with CHECKSTAT, and previous job name and id.
    It works fine for the side "the one after the others", BUT, wathever the previous job give as result (cancelled or finished), the next one starts whereas I pass the parameter CHECKSTAT to X.
    Any ideas of the problem and how to solve it?
    Thanks in advance for your answers.

    Here my code with explanation :
    REPORT  YCOMJ023.
    start-of-selection.
    "Initialization of my vars
    w_StepCount = 0. >> number of steps maxi in a job
    w_jobCount = 1.  >> number to see easier in SM37 the job order
    CONCATENATE pe_name '_STEPS' w_jobCountC INTO w_JobName. (example : TOTO_STEP1)
    CONDENSE w_JobName NO-GAPS.
    "I open my first job
      CALL FUNCTION 'JOB_OPEN' (OPEN job TOTO_STEP1)
        EXPORTING
          jobname          = w_JobName
        IMPORTING
          jobcount         = w_JobID
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
    "We keep in memory first job IDs to close it at the end of the prg
      w_firstjobName = w_JobName.
      w_firstjobID = w_JobID.
    "imagine you do the bellow code in a loop and it makes several jobs TOTO_STEP2 TOTO_STEP3 TOTO_STEP4...
    ADD 1 TO w_StepCount.
    IF w_StepCount GT 250.
        "I call close job eatch time I reach 250 steps
         PERFORM fx_jobclose.
    ENDIF.
    submit RKGALKEUB to sap-spool and return
                                       without spool dynpro
                                       spool parameters print_parameters
                                            VIA JOB w_JobName NUMBER w_JobID
    "End of the programmI close the current Job and the first one :
    "Current
            CALL FUNCTION 'JOB_CLOSE'
              EXPORTING
                JOBCOUNT             = w_JobId
                JOBNAME              = w_JobName
                PREDJOB_CHECKSTAT    = 'X'
                PRED_JOBCOUNT        = w_oldJobId
                PRED_JOBNAME         = w_oldJobName.
    "First one + launch with STRIMMED
            CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT             = w_firstjobId
              JOBNAME              = w_firstjobName
              STRTIMMED            = 'X'
            EXCEPTIONS
              cant_start_immediate = 1
              invalid_startdate    = 2
              jobname_missing      = 3
              job_close_failed     = 4
              job_nosteps          = 5
              job_notex            = 6
              lock_failed          = 7
              OTHERS               = 8.
    *&      Form  fx_jobclose
    *       text
    FORM fx_jobclose.
      "Step to zero to do a new loop after this form
      w_StepCount = 0.
      DATA : w_job_released TYPE CHAR1.
      "If the flag IsFirst, we don't do nothing, because it's the first JOb, and it should not be closed
      IF w_IsFirst = 'X'.
        "Flag is set to blank
        w_IsFirst = ''.
      ELSE.
          "Else it mean we are closing a job with predecessor :
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT             = w_JobId
              JOBNAME              = w_JobName
              PREDJOB_CHECKSTAT    = 'X'
              PRED_JOBCOUNT        = w_oldJobId
              PRED_JOBNAME         = w_oldJobName
              "SDLSTRTDT            = sy-datum
              "SDLSTRTTM            = sy-timlo
            IMPORTING
              JOB_WAS_RELEASED = w_job_released.
      ENDIF.
      "Vars get the value of current job, witch will become the older one
      w_oldJobId = w_jobID.
      w_oldJobName = w_JobName.
    "I make the new TOTO_STEPX job name
      ADD 1 TO w_jobCount.
      w_jobCountC = w_jobCount.
      CONCATENATE pe_name '_STEPS' w_jobCountC INTO w_JobName.
      CONDENSE w_JobName NO-GAPS.
      "I open the new job
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname          = w_JobName
        IMPORTING
          jobcount         = w_JobId
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
    ENDFORM.                    "fx_jobclose
    I hope my code is clear enought, I tried to delete the superfluities code.

  • Background Job with User Name

    I am trying to submit report program in background job. I want to submit it with specific user name so I am submitting with user name as 'ABC'  as below
    data: user type sy-uname.
    user = 'ABC'.
    SUBMIT z_program AND RETURN
                 WITH matnr = matnr
                 WITH werks = werks
                 USER user
                 VIA JOB jobname
                 NUMBER jobcount
    But it creates job with current user(sy-uname) running the program and  not 'ABC'. How I can change it for specified user?

    SUBMIT z_program AND RETURN
    WITH matnr = matnr
    WITH werks = werks
    USER user
    VIA JOB jobname
    NUMBER jobcount
    AND RETURN.    "you forgot to return back
    Of course the user should be the one existing in the system. I guess there is no such ABC. Find the one which exists (use i.e. su01).

  • Error generating report job with the task name 'FSRM_Report_Task

    Since this morning we have been having a problem with FSRM on Windows Server 2008 R2, it is no longer running storage reports (both scheduled and on-demand).
    We get the following in the event logs:
    Log Name:      Application
    Source:        SRMREPORTS
    Date:          09/06/2014 08:09:55
    Event ID:      752
    Task Category: None
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      FILESERVER2.curriculum.riddlesdown.local
    Description:
    Error generating report job with the task name 'FSRM_Report_Task{3add1760-4e79-4141-baba-cb53391bef3e}'.
    Context:
     - Exception encountered = Invalid argument: StorageType = '101'
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="SRMREPORTS" />
        <EventID Qualifiers="0">752</EventID>
        <Level>2</Level>
        <Task>0</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2014-06-09T07:09:55.000000000Z" />
        <EventRecordID>42920</EventRecordID>
        <Channel>Application</Channel>
        <Computer>FILESERVER2.curriculum.riddlesdown.local</Computer>
        <Security />
      </System>
      <EventData>
        <Data>Error generating report job with the task name 'FSRM_Report_Task{3add1760-4e79-4141-baba-cb53391bef3e}'.
    Context:
     - Exception encountered = Invalid argument: StorageType = '101'
    </Data>
      </EventData>
    </Event>
    We have uninstalled and reinstalled the FSRM role service but are still having the same problem.
    Anybody have any ideas?

    Hi,
    From the error message, it failed because of "invalid argument: storagetype = '101' ".
    101 means the storage type is "system" + "cache". Is there any change on your storage before the issue occurs? For example whether the source storage is changed?
    FsrmStorageModuleType enumeration
    http://msdn.microsoft.com/en-us/library/dd392346(v=vs.85).aspx
    If you have any feedback on our support, please send to [email protected]

  • Schedule job with JOB_CLOSE until a certain time

    Hello all,
    I'd like to schedule a background job with JOB_CLOSE until a certain time, i.e. first start time at 10 a.m., repitition period 15 min., last start time 1 p.m.
    I tried this using parameter LASTSTRTTM, e.g.:
    i_startdate = sy-datum.
    i_starttime = '100000'.
    i_prdmins = '15'.
    i_laststrtdt = sy-datum.
    i_laststrttm = '130000'.
    CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = l_jobcount
          jobname              = 'MY_JOB'
          sdlstrtdt            = i_startdate
          sdlstrttm            = i_starttime
          laststrtdt           = i_laststrtdt
          laststrttm           = i_laststrttm
          prdmins              = i_prdmins
        EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          OTHERS               = 8.
    but I didn't succeed - the job didn't stop at 1 p.m. Any hints?
    Best regards
    Martin Lehmann

    Hi Martin,
    i_startdate = sy-datum.  " 1st time Job Start Date
    i_starttime = '100000'.
    i_prdmins = '15'.
    i_laststrtdt = sy-datum.  " If Job is not started by this date, then it wont be started once this date is completed
    i_laststrttm = '130000'.
    What it means is, if i want to start a job by 10th Oct.. & expect that it should be started maximum by 20th Oct.. If its 20th Oct & still the job is not started,... then terminate the job & do not start it..
    If the job is already started, then it wont stop.
    Hope its clear.
    Best regards,
    Prashant

  • How to schedule job with spool list recipient in CPS ?

    Dear Guru,
    i import job with spool list recipient from r3 to cps and schedule in CPS, job is finished but there is no spool send to the recipient ?
    Please advise ?
    Best regards,
    Supat Jupraphat.

    What job definition did you use? SAP_AbapRun? SAP_AbapRunPrint? SAP_AbapRunPrintExt?
    Do you have XBP 2.0 or 3.0 in the SAP system? (check SE38 > INITXBP2)
    Have you loaded the CPS transport files in the SAP system?
    Note that using spoollist recipients either involves SAP_AbapRunPrintExt in combination with XBP3.0
    OR
    It involves SAP_AbapRun or SAP_AbapRunPrint and XBP 2.0 using transportation files in the SAP System.
    Please check the section of the CPS admin guide called: "Enhanced SAP Interfaces with Redwood Transports"
    Regards,
    David

  • Creating Job with CmdExe Step failed with error Reason : 5

    Hi, I setup a job with Type = Operating System (CmdExec) and Run as 'SQL Server Agent Service Account' , it failed to run with Message below :
    Message
    Executed as user: PROD\sqlserveragent. The process could not be created for step 4 of job 0x5A83AE4A12AEF649888E85F4072604F6 (reason: 5).  The step failed.
    1. I couldn't find what is meaning of Reason 5 here.
    2. This step used to work previously and it 'not working' suddenly these few days. I wondering anyone make the changes but I am not able to trace it. Any guide to troubleshoot would be helpful.
    Thanks .

     Operating System ... (reason: 5).  The step failed.
    Operating System Error code 5 = Access denied, seems to be a permission issue.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

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

    Hi,
    This might sound really remedial, but can someone explain to me how I go about creating a job with arguments with programs. It errors out when I try to use DEFINE_PROGRAM_ARGUMENTS and when I try to use SET_JOB_ARGUMENTS_VALUE. Maybe it's the order I do it in. Any directions would be much appreciated. Thanks!
    Tony

    Hi Tony,
    Almost any internal error is an Oracle bug and you should report this to support.
    This is definitely not supposed to happen and I haven't seen this error before, do you have a test case throwing the error ?
    Using program arguments should be fairly straightforward. Here's a simple example with two varchar2 arguments
    -- create a stored procedure with two arguments
    create or replace procedure myproc (arg1 in varchar2, arg2 in varchar2)
    is BEGIN null; END;
    -- create a program with two arguments and define both
    begin
    dbms_scheduler.create_program
    program_name=>'myprog',
    program_action=>'myproc',
    program_type=>'STORED_PROCEDURE',
    number_of_arguments=>2, enabled=>FALSE
    dbms_scheduler.DEFINE_PROGRAM_ARGUMENT(
    program_name=>'myprog',
    argument_position=>1,
    argument_type=>'VARCHAR2',
    DEFAULT_VALUE=>'13');
    dbms_scheduler.DEFINE_PROGRAM_ARGUMENT(
    program_name=>'myprog',
    argument_position=>2,
    argument_type=>'VARCHAR2');
    dbms_scheduler.enable('myprog');
    end;
    -- create a job pointing to a program and set both argument values
    begin
    dbms_scheduler.create_job('myjob',program_name=>'myprog');
    dbms_scheduler.set_job_argument_value('myjob',1,'first arg');
    dbms_scheduler.set_job_argument_value('myjob',2,'second arg');
    dbms_scheduler.enable('myjob');
    end;
    Hope this helps,
    Ravi.
    -Ravi

Maybe you are looking for