Time and event-based jobs

Jobs scheduled based on time in DBMS_SCHEDULER. Can we changed to event-based without dropping the job?
Thanks in advance.

Hi,
You can try this :
- disable the job
- set event_spec to be NULL for the job e.g.
exec dbms_scheduler.set_attribute_null('j1','event_spec')
- use set_attribute to set your time-based schedule
- re-enable the job
This should work.
Hope this helps,
Ravi.

Similar Messages

  • Query on event based job in a client schema and not SYS schema

    Hi, I am fairly new to oracle job scheduler and wanted your inputs on how to create a event based job that sends a mail based on success of another job.
    I was able to implement this with the jobs being created under SYS schema. I did get email notifcation when errors were logged in exception table.
    However, now the requirement has changed to create the jobs under a client specific schema.
    The jobs got created successfully in CLIENT schema but the event based job is not working. It does not send the email notification.
    I feel this is to do with not correctly subscribing to the event queue {sys.scheduler$_event_queue}.
    Can CLIENT schema use the agent "AGENT" created under SYS to subscribe to the Scheduler event queue {sys.scheduler$_event_queue}? CLIENT is the schema in which the all jobs and procedures are created.
    BEGIN
    DBMS_AQADM.ENABLE_DB_ACCESS('AGENT', 'CLIENT');
    END;
    --Main Job that will load data and errors will be logged into exception table
    BEGIN    
    dbms_scheduler.create_job( job_name=> 'CLIENT.LOAD_DATA',                              
    job_type=>'PLSQL_BLOCK',                              
    job_action=>'BEGIN  CLIENT.p_loaddata;                                     
    END;',                              
    start_date=>systimestamp,                              
    repeat_interval=>'FREQ=MINUTELY;INTERVAL=1;',                              
    number_of_arguments=>0,                              
    enabled=> true);
    END;
    --set raise_events attribute = job_succeeded for main job
    BEGIN
    DBMS_SCHEDULER.set_attribute ('CLIENT.LOAD_DATA', 'raise_events', DBMS_SCHEDULER.job_succeeded);
    END;
    --Event Job that will send email based on condition. Condition is checked in procedure CLIENT.p_check_sendmail; If errors are found in the exception table, this job will raise exception and will be JOB_FAILED status. This job will send a email notification.
    BEGIN 
    DBMS_SCHEDULER.create_job (       job_name          => 'CLIENT.EMAIL_JOB',     
    job_type          => 'PLSQL_BLOCK',     
    job_action        => 'BEGIN  CLIENT.p_check_sendmail;                                   END;',     
    event_condition  => 'tab.user_data.event_type = ''JOB_SUCCEEDED'' and tab.user_data.object_name = ''LOAD_DATA''',      
    queue_spec        => 'sys.scheduler$_event_queue,AGENT',      
    enabled          => true);
    END;
    BEGIN    
    dbms_scheduler.add_job_email_notification ( job_name => 'CLIENT.EMAIL_JOB',     recipients => '[email protected]',events => 'JOB_FAILED');
    END;
    Is the way i am subscribing to the event queue correct? Could you please share an example/document of event based job in a schema other than SYS and how subscription is being done to event queue?
    Thanks

    Hi,
    It's a good decision you made because you shouldn't create objects in the SYS schema. I see you're using the add_job_email_notification procedure, so I'm assuming you're on 11g onwards.
    This procedure is meant to make the job easy for you. That is, you don't need to worry about setting up AQ, the procedure does it all for you. All you need to do is setup the mail server if not already done, and call this procedure to add the mail notification. That's it.
    You can also specify a filter to the add_job_email_notification procedure, so maybe you could specify directly your CLIENT.LOAD_DATA job to this procedure.

  • Scheduler - Event Based Jobs

    Hi,
    I've been trying to create an event based job dependent on multiple jobs. I tried queuing, but it seems like it can only hand one Job at a time. Also, chains were recommended to me, but I want the Job to run on the dependence on the Job that ran on specific program at the specific time. I currently know that chains can only handle, programs, other chains and/or events.
    In my mind chains wouldn't work, because If I wanted to run Job3 dependent on the outcome of Job1 running Program1 and Job2 running Program2, chains wouldn't be able to accomdate that. For it to happen in chains I would have to attach Program1 and Program2 to the new chain Job and that is not exactly what I would want.
    Can anyone help/clarify this situation for me. Thank you.
    Tony

    Hi Tony,
    So the requirement is to run a job after 2 prior jobs have completed.
    There are two ways I can think of to do this, both using events. In both cases you need to set job A and job B to raise events on completion (succeeded, failed or stopped) and setup an agent for the Scheduler event queue in the schema in which you are working
    dbms_scheduler.add_event_queue_subscriber('myagent')
    In order to get Job C to start after jobs A and B have completed there are 2 options.
    1) Let job C point to a chain and start running whenever job A has completed. The chain will have 2 steps, one event step waiting on B and one that runs your task C. An event step does nothing but wait for a particular event and complete successfully when the event is received. The second step will run when the event step waiting on job B has completed.
    So your chain would look something like
    begin
    dbms_scheduler.create_chain('chain1');
    dbms_scheduler.define_chain_event_step('chain1','stepB',
    'tab.user_data.object_name = ''JOB_B'' and
    tab.user_data.event_type IN(''JOB_SUCCEEDED'',''JOB_FAILED'',''JOB_STOPPED''',
    'sys.scheduler$_event_queue,myagent');
    dbms_scheduler.define_chain_step('chain1','stepC','finalTaskProg');
    dbms_scheduler.define_chain_rule('chain1','true','start stepB');
    dbms_scheduler.define_chain_rule('chain1', 'stepB completed', 'start stepC');
    dbms_scheduler.define_chain_rule('chain1', 'stepC completed', 'end');
    dbms_scheduler.enable('chain1');
    end;
    And your job would point to the chain and run whenever job_A completes (similar condition and queue_spec). It would keep waiting till job_B runs and then the final task would run and it would complete.
    2) The second way is to require job_A to insert a row into a table somewhere. Rule conditions can access table data so you could have job_C have an event condition which checks for a completion event for job_B and checks the table to see whether job_A has completed. Then the code you run should then remove the row in the table
    e.g.
    queue_spec=>'sys.scheduler$_event_queue,myagent'
    event_condition=>'tab.user_data.object_name = ''JOB_B'' and
    tab.user_data.event_type IN(''JOB_SUCCEEDED'',''JOB_FAILED'',''JOB_STOPPED''' and
    (select count(*) from mytab where col='job_A')>0'
    Then when running C do - delete from mytab where col='job_a';
    Both of these assume that job_A always completes before job_B but both of these will then run job_C after job_B completes. Modifying either of these so that either job A or B runs first is also possible by having another job that waits on A rather than B.
    Hope this helps, if you have any more questions, let me know.
    -Ravi

  • How to limit the number of parallel instances of a given event-based job?

    Hi,
    DB version : 11.2.0.3
    I'm using an event-based job with parallel_instances attribute set to true.
    It works perfectly fine, messages are enqueued then dequeued and processed simultaneously by separate instances of the same job.
    Now, I'd like to limit the number of parallel instances of this job running at the same time, say to an arbitrary number n.
    What would be the best way to do that?
    Maybe using a notification callback is a better option in this case?
    Thanks in advance for any input.

    Hi,
    DB version : 11.2.0.3
    I'm using an event-based job with parallel_instances attribute set to true.
    It works perfectly fine, messages are enqueued then dequeued and processed simultaneously by separate instances of the same job.
    Now, I'd like to limit the number of parallel instances of this job running at the same time, say to an arbitrary number n.
    What would be the best way to do that?
    Maybe using a notification callback is a better option in this case?
    Thanks in advance for any input.

  • Error in creating event based  jobs.

    while trying to creating event based jobs. I am getting below error
    ORA-00904: "SYS"."SCHEDULER$_QP_5187"."F3": invalid identifier
    ORA-06512: at "SYS.DBMS_ISCHED", line 99
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 295
    ORA-06512: at line 2
    I am using 10g database.
    Even below small procedure is not working.
    begin
    DBMS_SCHEDULER.create_job
                         ('test1F' ,
                          job_type             => 'plsql_block',
                          job_action           =>    'begin  test_proc end;',
                          event_condition      =>    'tab.user_data.object_name ='' test''  and  tab.user_data.event_type = ''JOB_FAILED''',
                          queue_spec           => 'sys.scheduler$_event_queue,myagent',
                          enabled              => TRUE
    end; and
    Myagent is subscribe to
    SELECT consumer_name
      FROM dba_queue_subscribers
    WHERE queue_name = 'SCHEDULER$_EVENT_QUEUE';
    MYAGENT
    SCHEDULER$_EVENT_AGENTEdited by: ma**** on 25-Aug-2012 01:55

    Please lock this thread, post to the scheduler forum, and when you do include sufficient information for someone to help you ... this isn't it.
    What version number.
    What is the code you are running?
    In what schema with what explicit and role-based permissions?
    At what point do you get the error? The way it is posted, above, it is impossible to be sure.

  • Documentation for tab.user_data with event based jobs

    Hi,
    Are all the atributes for tab.user_data when used as part of an event based job documented somewhere?
    I have been looking but all I can find are examples rather than explicit documentation.
    Thanks
    Pete

    Hi Pete,
    The type of the object tab.user_data is the type used to create the AQ queue with. So it varies depending on the type you used to create the queue with.
    If you are consuming messages from the scheduler event queue, the type is sys.scheduler$_event_info and to figure out what fields it has you can use
    desc sys.scheduler$_event_info
    Hope this helps,
    Ravi.

  • Event based job

    we have a job that needs to be restarted after db reboot,is it possible to create an event based inside oracle that starts the queue and our main job for us ?
    v11.2

    Hello;
    Oracle has an System Event Trigger "AFTER STARTUP" which could be used for this.
    "Ask Tom" has a note on this with example :
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:49818662859946
    ( This shows after logon, but you should be able to use the example with the other trigger )
    Best Regards
    mseberg
    OR
    http://www.datadisk.co.uk/html_docs/oracle/scheduler.htm
    http://psoug.org/reference/dbms_scheduler.html
    Edited by: mseberg on Nov 3, 2011 9:31 AM

  • Using AS2 to get time and change based on result

    I need to make an edit to a flash projector that was built some time ago that changes what is playing based on the time of day. It is used to advertise breakfast or lunch/dinner for a restaurant. Previously we had set it up so that the time change happened at 5 in the morning and 10 in the morning. The code is below. The restaurant wants to change the time switch to be on the half hour now. I know how to pull the hours and minutes to do this.
    This is the code I have been using
    var currentHours:Date = new Date();
    var currentMin:Date = new Date();
    timeInHours = currentHours.getHours();
    timeInMin = currentMin.getMinutes();
    var now:Date = new Date();
    shownow = now.setMilliseconds;
    if (timeInHours > 4 && timeInHours < 11 ){
    breakfast_mc._visible = true;
    breakfast_mc.play();
    dinner_mc._visible = false;
    dinner_mc.stop();
    //trace(timeInHours);
    } else {
    breakfast_mc._visible = false;
    breakfast_mc.stop();
    dinner_mc._visible = true;
    dinner_mc.play();
    //trace(timeInHours);
    trace(timeInHours);
    trace(timeInMin);
    stop();
    The breakfast and dinner movie clips have this code in them as well, so than at the end of each cycle, it checks the time and will switch.
    I found this code on Flash Kit and wanted to try and modify it, My hope was to get it to generate a 24hr time 1604 or 1029 that I could then do a < / > comparison with, but this function adds the numbers together so 4:15 PM = 31 and 12:19 = 31 also. Does anyone have any suggestions about how I can do this? I need the time to change at 5 AM and 10:30 AM.  There is a possibility that they may want to extend it out to include day of the week as well. RIght now I just need fractional hours to work though.
    function checkTime()
    var dat = new Date();
    var hr = dat.getHours(); // this is 24-hour format already...
    var mn = dat.getMinutes();
    // round to most recent 15 minute boundary
    //mn = Math.floor(mn/15) * 15;
    // OPTIONAL - add leading zeros to hr and minute
    if (hr < 10)
    hr = "0" + hr;
    if (mn < 10)
    mn = "0" + mn; // remove these last 4 lines if leading zeros not wanted
    return hr + mn;
    // example usage:
    time = checkTime();
    trace( time );
    Any and all suggestions are welcome. Thanks in advance!

    Hi Kglad,
    Thanks for your response, I am trying the code now and I am having some difficulty with it. This is probably so simple, but I can't see it.
    var d:Date=new Date();
    if ((d.getHours()>=5 && d.getHours()<10) || (d.getHours()==10 && d.getMinutes<=30)){
    breakfast_mc._visible = true;
    breakfast_mc.play();
    dinner_mc._visible = false;
    dinner_mc.stop();
    trace("it is breakfast time");
    } else {
    breakfast_mc._visible = false;
    breakfast_mc.stop();
    dinner_mc._visible = true;
    dinner_mc.play();
    trace("it is lunch time");
    stop();
    Once it is past 10:30 I want the dinner movie clip to play and the breakfast clip to stop and disappear. After 5 in the morning, I want the dinner clip to stop and the breakfast one to start.
    I've tried < and > with minutes and neither seems to work. The hours work, I set up a test clip with this script in it and when I change my computer clock, I can make this switch back and forth with hours but the minutes still do not factor in.
    Thanks

  • Can't Seem to Get my Event Based Job To Execute

    What makes this slightly different than other posts on this topic is that we want to use our own queue/payload object rather than the built-in SCHEDULER$_EVENT_QUEUE. There are many reasons for this. What follows in under 11gR2 (11.2.0.3)
    So, the following code blocks are just for a proof of concept piece intended to create a simple job and to have it fired based on the arrival of a message in a queue. (Something we have a requirement to do) The issue that I just can't seem to resolve is that, for some reason, the scheduler object never triggers the job. I can't find any trace or alert log entries to help me diagnose. What I do know is that the queue itself is fine (dequeues and enqueues work normally). The object payload type is fine (All of these tested from the EVENT_JOB_MGR package provided below).
    Here's the PL/SQL Type that is the payload object of the queue and is also referenced in the package:
    CREATE OR REPLACE TYPE RUN_MSG AS OBJECT
      STATUS VARCHAR2(255)
    Here are the queue and queue table:
    BEGIN
      DBMS_AQADM.CREATE_QUEUE_TABLE
        QUEUE_TABLE           =>        'JUPSHAW.EVENT_JOB_QT'
       ,QUEUE_PAYLOAD_TYPE    =>        'JUPSHAW.RUN_MSG'
       ,COMPATIBLE            =>        '10.0.0'
       ,STORAGE_CLAUSE        =>        '
                                         TABLESPACE RISKDM_DATA'
       ,SORT_LIST             =>        'ENQ_TIME'
       ,MULTIPLE_CONSUMERS    =>         TRUE
       ,MESSAGE_GROUPING      =>         0
       ,SECURE                =>         FALSE
    End;
    BEGIN
      DBMS_AQADM.CREATE_QUEUE
        QUEUE_NAME          =>   'JUPSHAW.EVENT_JOB_Q'
       ,QUEUE_TABLE         =>   'JUPSHAW.EVENT_JOB_QT'
       ,QUEUE_TYPE          =>   SYS.DBMS_AQADM.NORMAL_QUEUE
       ,MAX_RETRIES         =>   0
       ,RETRY_DELAY         =>   0
       ,RETENTION_TIME      =>   -1
    END;
    DECLARE
      aSubscriber sys.aq$_agent;
    BEGIN
      aSubscriber := sys.aq$_agent('SCHEDULER$_EVENT_AGENT',
                                  0);
      dbms_aqadm.add_subscriber
         ( queue_name     => 'EVENT_JOB_Q'
          ,subscriber     => aSubscriber);
    END;
    BEGIN
      SYS.DBMS_AQADM.START_QUEUE
        QUEUE_NAME => 'JUPSHAW.EVENT_JOB_Q'
       ,ENQUEUE => TRUE
       ,DEQUEUE => TRUE
    END;
    (I think the scheduler automatically added itself as a subscriber (see above) after the queue itself was created)
    So, here's the simple package:
    CREATE OR REPLACE PACKAGE EVENT_JOB_MGR
    AS
        PROCEDURE DEQUEUE_JOB_STATUS_MSG;
        PROCEDURE ENQUEUE_JOB_STATUS_MSG;
        PROCEDURE RECORD_DEQUEUED_STATUS( a_RunMsg  RUN_MSG );
    END EVENT_JOB_MGR;
    CREATE OR REPLACE PACKAGE BODY EVENT_JOB_MGR
    AS
        PROCEDURE RECORD_DEQUEUED_STATUS( a_RunMsg  RUN_MSG )
        IS
            ls_Status       VARCHAR2(32);
        BEGIN
            ls_Status := a_RunMsg.STATUS;
            INSERT INTO DEQUEUE_RECORD
            ( STATUS )
            VALUES
            ( ls_Status );
            COMMIT;    
        END;       
        PROCEDURE DEQUEUE_JOB_STATUS_MSG
        IS
            l_DeQOptions    DBMS_AQ.DEQUEUE_OPTIONS_T;
            l_MsgProps      DBMS_AQ.MESSAGE_PROPERTIES_T;
            l_DeQMsgID      RAW(16);
            l_RunMsg        RUN_MSG;                
        BEGIN
            l_DeQOptions.CONSUMER_NAME := 'EVENT_JOB';
            DBMS_AQ.DEQUEUE(    queue_name          =>  'EVENT_JOB_Q',
                                  dequeue_options     =>  l_DeQOptions,
                                  message_properties  =>  l_MsgProps,
                                  payload             =>  l_RunMsg,
                                  msgid               =>  l_DeQMsgID );
            COMMIT;                             
            RECORD_DEQUEUED_STATUS( l_RunMsg );                              
        END;
        PROCEDURE ENQUEUE_JOB_STATUS_MSG
        IS
            l_EnQOptions    DBMS_AQ.ENQUEUE_OPTIONS_T;
            l_MsgProps      DBMS_AQ.MESSAGE_PROPERTIES_T;
            l_EnQMsgID      RAW(16);
            l_RunMsg        RUN_MSG;               
        BEGIN   
            l_RunMsg := RUN_MSG('Success');
            DBMS_AQ.ENQUEUE(  QUEUE_NAME          =>  'EVENT_JOB_Q',
                                ENQUEUE_OPTIONS     =>  l_EnQOptions,
                                MESSAGE_PROPERTIES  =>  l_MsgProps,
                                PAYLOAD             =>  l_RunMsg,
                                MSGID               =>  l_EnQMsgID);
        END;
    END EVENT_JOB_MGR;
    -- Finally the program, schedule and job
    BEGIN
        DBMS_SCHEDULER.CREATE_PROGRAM(
            PROGRAM_NAME          => 'EVENT_JOB_PROG',
            PROGRAM_ACTION        => 'EVENT_JOB_MGR.RECORD_DEQUEUED_STATUS',
            PROGRAM_TYPE          => 'STORED_PROCEDURE',
            NUMBER_OF_ARGUMENTS   => 1,
            ENABLED               => FALSE );
        DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT (
            program_name        => 'EVENT_JOB_PROG',
            argument_position   => 1,
            metadata_attribute  => 'EVENT_MESSAGE' );  
        DBMS_SCHEDULER.ENABLE( NAME => 'EVENT_JOB_PROG');        
    EXCEPTION
      WHEN OTHERS THEN RAISE ;       
    END;
    COMMIT
    BEGIN
      DBMS_SCHEDULER.CREATE_EVENT_SCHEDULE (
       schedule_name     =>  'EVENT_JOB_SCHED',
       start_date        =>  SYSTIMESTAMP,
       event_condition   =>  'TAB.USER_DATA.STATUS = ''SUCCESS''',
       queue_spec        =>  'EVENT_JOB_Q');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_JOB (
       job_name            =>  'EVENT_JOB',
       program_name        =>  'EVENT_JOB_PROG',
       schedule_name       =>  'EVENT_JOB_SCHED',
       enabled             =>  TRUE,
       comments            =>  'Start if you get a success message');
    END;
    I call the ENQUEUE_JOB_STATUS_MSG method to stick a message on the queue. I can confirm that it can be dequeued and logged using the DEQUEUE_JOB_STATUS_MSG method in the package. However, nothing seems to happen (at all) as far as the scheduler job when a message is put on the queue. I am thinking it should dequeue the message with status set to SUCCESS and then, kick off the job.
    Can anyone see why the above wouldn't work? Been stuck here for a couple of days.
    Thanks,
    -Joe

    Try to create job that react on event directly not using schedule.
    BEGIN
        dbms_scheduler.create_job(job_name => 'EVENT_JOB',
                                  program_name =>  'EVENT_JOB_PROG',
                                  event_condition => 'TAB.USER_DATA.STATUS = ''SUCCESS''',
                                  queue_spec => 'EVENT_JOB_Q',
                                  enabled => true,
                                  auto_drop => FALSE);
    END;
    Check if your schedule EVENT_JOB_SCHED is enabled

  • Trigger by time and event

    Hi Gurus,
    Is it possible to have a batch job or process chain to be triggered by BOTH an event AND time at the same time?
    How about for a job or chain to be triggered ONLY when 2 Events have triggered?
    So far, I see that only 1 event is possible per trigger.
    Can a program check if a particular event has been triggered? Is this status set/saved in a table?
    Thanks,
    Pascal Gabin

    Dear Pascal Gabin,
    I hate to write the following logic.. but just thining if incase if youhave not thought of this.
    1) EVENT A, linked to ABAP A
    2) EVENT B, linked to ABAP B
    Logic ABAP A:
       - Updates FLAG A, table COMMON. 
       - Checks the Flag B is X or not..
            if it is Space.
               exit.
            else.
               clear the FLAGS.
             Trger the event C, by BP:EVENT_RAISE FM.      
    Logic ABAP B:
       - Updates FLAG B, table COMMON. 
       - Checks the Flag A is X or not..
            if it is Space.
               exit.
            else.
               clear the FLAGS.
             Trger the event C, by BP_EVENT_RAISE FM.      
    Event C is maaped to your Process chian or JOB..
    Not a good one.. but i think it can satify the functionality of what your loking for..
    table Common will have 2 fields FLAG_A and FLAG_B.
    jst trying to read FLAGS instead of events..
    You can also check for event tables in the work flow form.. not sure you get it.. but should give you many table names there..
    regards,
    Hari

  • Event Based Jobs

    Hi,
    I have 3 jobs A, B, and C (we do not want to use a chain).
    My intention is for the jobs to run in sequence, A->B->C, however their run times should not overlap.
    Also I want to specify the multiple event conditions.
    For example B should not start if A is running and C should not start if A or B are running.
    I tried the specify the below event_condition for job C. It is not working.
    Event_Condition => tab.user_data.object_name=''EBJ_A'' and tab.user_data.object_name=''EBJ_B''
    Please provide any suggestions that I can use.
    Thanks,
    Sreenath.

    SEE THIS EXAMPLE:
    The following example creates a chain where first my_program1 runs. If it succeeds, my_program2 runs; otherwise, my_program3 runs.
    BEGIN
    DBMS_SCHEDULER.CREATE_CHAIN (
    chain_name => 'my_chain2',
    rule_set_name => NULL,
    evaluation_interval => NULL,
    comments => NULL);
    END;
    --- define three steps for this chain.
    BEGIN
    DBMS_SCHEDULER.DEFINE_CHAIN_STEP('my_chain2', 'step1', 'my_program1');
    DBMS_SCHEDULER.DEFINE_CHAIN_STEP('my_chain2', 'step2', 'my_program2');
    DBMS_SCHEDULER.DEFINE_CHAIN_STEP('my_chain2', 'step3', 'my_program3');
    END;
    --- define corresponding rules for the chain.
    BEGIN
    DBMS_SCHEDULER.DEFINE_CHAIN_RULE ('my_chain2', 'TRUE', 'START step1');
    DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
    'my_chain2', 'step1 SUCCEEDED', 'Start step2');
    DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
    'my_chain2', 'step1 COMPLETED AND step1 NOT SUCCEEDED', 'Start step3');
    DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
    'my_chain2', 'step2 COMPLETED OR step3 COMPLETED', 'END');
    END;
    /

  • JS: How to make a script to print one page at a time and set print job name?

    What I want is to print one page at a time to the printer.
    Document.print(false, app.printerPresets.item(0)) almost get me there. But how do I get it to print page by page? There seems to be no way to set which page to print to printerPreset.
    Also, is it possible to change print job name from the default of using document name?

    >Is there any solution to this other than saving the document to a different name before each page print?
    Here is an altered and abriged version of the script that I use. I use print preset called "PS to PDF" in it, so you should change it to your own.
    if(app.documents.length == 0){
       alert("Please open a document and try again.");
       exit();
    var myFolder = Folder ("~/Desktop");
    var myDoc = app.activeDocument;
    var myNoExtention = getFileNameOnly (myDoc.name);
    var myPrintPrefs = myDoc.printPreferences;
    if (app.printerPresets.item("PS to PDF") == null) {
       alert("Preset \"PS to PDF\" has not been installed");
       exit();
    else {
       myPrintPrefs.activePrinterPreset = app.printerPresets.item("PS to PDF"); 
    myDoc.sections.everyItem().sectionPrefix = "";
    myDoc.sections.everyItem().includeSectionPrefix = false;
       var stop = myDoc.pages.length;
       var w = new Window ( 'window', 'Printing PS-files' );
       var pb = w.add ('progressbar', [12, 12, 300, 24], 0, stop);
       var txt = w.add('statictext');
       txt.bounds = [0, 0, 200, 20];
       txt.alignment = "left";
       w.show()
    for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++){
       curPage = myCounter + 1;
       pb.value = curPage;
       var myText = String("Page " + curPage + " of " + myDoc.pages.length);
       txt.text = myText;       
       var myPageName = myDoc.pages.item(myCounter).name;
       var cornumber = pagenum(myPageName);
       var myFilePath = myFolder + "/" + myNoExtention + "_" + cornumber + ".ps";
       var myFile = new File(myFilePath);
       myPrintPrefs.pageRange = myPageName;
       myPrintPrefs.printFile = myFile;
       myDoc.print(false);
    w.hide();
    alert("Done!");
    function pagenum(myNumber){
       if (myNumber >= 1 && myNumber <= 9)
       x =  "0" + "0" + myNumber;
       else if (myNumber >= 10 && myNumber <= 99)
       x = "0" + myNumber;
       else if (myNumber >= 100 && myNumber <= 999)
       x = myNumber;
    return x
    function getFileNameOnly (myFileName) {
       var myString = "";
       var myResult = myFileName.lastIndexOf(".");
       if (myResult == -1) {
          myString = myFileName;
       else {
          myString = myFileName.substr(0, myResult);
       return myString;
    Kasyan

  • Events Based Scheduling

    Database Ver. 11gR2 (11.2.0.2.0)
    Hi Guys,
    How do you run jobs in oracle scheduler based on events? I have a job that needs to run after the successful completion of another job. I don't want to use chains. I have searched on the web, but all the examples I see are where a temp table is created and a row is inserted and then another PL/SQL block is run to manually pass a 'GO' value. I am looking for the a job to raise the JOB_SUCCEEDED event and then another job kicks in based on this event.
    Any detailed examples would be greatly appreciated. Also if using any other PL/SQL package, what necessary privileges would be required to execute that package.
    Thanks in advance.
    VB

    Here is a simple example. You create a job, MY_JOB, that raises the job_succeeded event. You also create an event-based job, MY_JOB_CONSUMER, that consumes event messages from sys.scheduler$_event_queue but only for job_succeeded events raised by MY_JOB.
    First you let the user subscribe to the Scheduler event queue using the ADD_EVENT_QUEUE_SUBSCRIBER procedure. “my_agent”, or whatever name you use, is the name of the Oracle Streams Advanced Queuing (AQ) agent to be used to subscribe to the Scheduler event queue. This call both creates a subscription to the Scheduler event queue and grants the user permission to dequeue using the designated agent. The subscription is rule-based. The rule permits the user to see only events raised by jobs that the user owns, and filters out all other messages:
    DECLARE
       agent_already_subscribed_exp   EXCEPTION;
       PRAGMA EXCEPTION_INIT (agent_already_subscribed_exp, -24034);
    BEGIN
       sys.DBMS_SCHEDULER.add_event_queue_subscriber ('my_agent');
    EXCEPTION
       WHEN agent_already_subscribed_exp
       THEN
          NULL;
    END;
    /Then you create MY_JOB_CONSUMER:
    BEGIN
       sys.DBMS_SCHEDULER.create_job (
          job_name          => 'MY_JOB_CONSUMER',
          job_type          => 'PLSQL_BLOCK',
          job_action        => '/* Add you code here */ NULL;',
          event_condition   => 'tab.user_data.event_type = ''JOB_SUCCEEDED'' and tab.user_data.object_name = ''MY_JOB''',
          queue_spec        => 'sys.scheduler$_event_queue,my_agent',
          enabled           => TRUE);
    END;
    /Now, MY_JOB_CONSUMER is waiting for a message to arrive in sys.scheduler$_event_queue. It will dequeue it only if the condition in event_condition is true.
    Create a one time job, MY_JOB, set its raise_events attribute to job_succeeded and enable it:
    BEGIN
       sys.DBMS_SCHEDULER.create_job (job_name     => 'MY_JOB',
                                      job_type     => 'PLSQL_BLOCK',
                                      job_action   => '/* Add you code here */ NULL;',
                                      start_date   => SYSTIMESTAMP AT TIME ZONE 'US/Pacific',
                                      auto_drop    => TRUE,
                                      enabled      => FALSE);
       DBMS_SCHEDULER.set_attribute ('MY_JOB', 'raise_events', DBMS_SCHEDULER.job_succeeded);
       sys.DBMS_SCHEDULER.enable ('MY_JOB');
    END;
    /When MY_JOB executes, it will enqueue a message in sys.scheduler$_event_queue. MY_JOB_CONSUMER will then pick it up and consume it.
    Hope that simple demonstration helps.

  • EVENT BASED SCHEDULER

    Hi All,
    I have two databases lets say A an B.
    I have a STORED PROCEDURE on DATABASE B which runs everyday via a schecduler at 8 in the morning.
    This procedure basically picks up data from a TABLE in database A and processes it everyday.
    Now I want to modify the scheduler from the current one that runs at say 8 to one that runs the STORED PROCEDURE whenever data is inserted into the table.
    Is it possibble in ORACLE?
    Datbase version is 10g
    Any help would be highly appreciated.

    Elessar wrote:
    Hi All,
    I have two databases lets say A an B.
    I have a STORED PROCEDURE on DATABASE B which runs everyday via a schecduler at 8 in the morning.
    This procedure basically picks up data from a TABLE in database A and processes it everyday.
    Now I want to modify the scheduler from the current one that runs at say 8 to one that runs the STORED PROCEDURE whenever data is inserted into the table.
    Is it possibble in ORACLE?
    Datbase version is 10gHere is one way of doing it:
    Oracle Scheduler - Event Based Jobs.
    One way of re-using it is, raising an Event trigger to Kick-off the jobs, preferably once data is inserted into tables. Definitely, this has to be done by the system performing the Inserts.

  • Batch job scheduling based on Event AND for the job to complete

    I am trying to schedule a background job based on an event AND based on the job finishing itself.
    Example:
    Job name: Send_Message
    After Event: SAP_NEW_PROCESS Message
    Program:  Program xxxx
    I want that the Send_Message job only runs when the Event SAP_NEW_PROCESS message happens AND the Send_Message job is not running.
    Right now, I could only schedule it based on the event SAP_NEW_PROCESS Message which means that everytime this event happens the job runs and I end up having the job "Send_Message" in multilple intances where the others will immediately cancel since the first job is still running and so I end up with a lot of Cancelled job when it is not necessary to run them all when there is already 1 instance of the Job running.
    How do I set it up in SAP?

    Thanks but I am new to SAP having to set up a batch job.
    The Event "SAP_NEW_PROCESS_MESSAGES" is a standard SAP Event.  We used that such that when a new transaction comes in, the batch job will run but we don't want to run the batch job if the same batch job is already running.
    YOu mentioned that I should set up Job_0.  Do I need to create an ABAP prorgram to check if JOB_1 is running?  How do I set up Job_0?  What is the trigger for my Job_0 to run?
    You also said that I set up Job_1 and trigger that based on the outcome of Job_0 AND at the same time be triggered by the event "SAP_NEW_PROCESS_MESSAGES".  How do I set up  this Job_1 so that it can be triggered by both Job_0 and a new transaction coming in(SAP_NEW_PROCESS_MESSAGES).
    if you can provide me the step by step guide as I am new to this and I only know basic.
    The current set up I have is
    Job_1
    Job Start:
          After Event
                Event: SAP_NEW_PROCESS_MESSAGES
          Step 1: program to run RCOCB002
    I was thinking following your suggestion is this:
    Job_0
    Job Start
          After Event
                Event: SAP_NEW_PROCESS_MESSAGES
          Step 1: program to run - What will be my program to run?
    Job_1
    Job_Start
          After Event
                Event: What will be my trigger for Job_1 and how do I set it up?
          Step 1: program to run RCOCB002
    Edited by: Shirley Te on Mar 10, 2010 3:25 PM

Maybe you are looking for

  • Accessing the field values in different fields for calculation

    Hi, I am creating a report in which I have used breaks for grouping the  customers by their category. I have used summary on the amount field to calculate the sum in the individual category and also for total amount. Now, I also want to add an column

  • FillSchema picks too many primary key columns

    I don't know whether this is an ODP.NET error or a Microsoft error. Oracle9i Release 9.2.0.1.0 ODP.NET 9.2.0.4 .NET Framework 1.1 Create a table with one primary key column and one unique column and name the primary key column like the unique column

  • Can not open drop box on web sight

    I am on a govenment websight I can open the drop box on my computer but can not on my samsung tablet

  • Problem trying to run 32 bit VBA program on a 64 bit machine

    I am a new programmer using VBA in Excel. I have used code that refers to a kernel32 in the VBA code. This code fails on a 64 bit machine. Runs perfectly fine on 32 bit machine. Is there code I can add that will allow the program to run on both syste

  • OS X system utility

    Hi, can anyone tell me what is the best free system utility for os x? I want something to clean up my hard drive, delete duplicate files, cashes etc and generally make my mac run smoother and faster.