Materialized View to run only once in a year...

Hi everybody...
I want to create a materialized view which will run only once in a year and specifically some minutes after 00:00 a.m. on new year's day,
so i created the following:
CREATE MATERIALIZED VIEW <mv_name>
BUILD IMMEDIATE
REFRESH START WITH TO_DATE('01/01/2007 00:15:00','DD/MM/RRRR HH24:MI:SS')
NEXT SYSDATE+366
I have two notes:
1) how to declare the refresh to be done the first new year's day after the day it'll be created , i mean not static date (01/01/2007)
2)some years are leap and some are not , so in order to run every new year's day how should i transform the above..????
3)is there any view which displays the next run of a materialized view..???
the view DBA_MV_REFRESH_TIMES displays the last refresh of mv's...
I use Oracle 10.2.0.1 on XP ...
Thanks , a lot
Simon

1).
use the expression that evaluates to next january first.
SQL> select sysdate, add_months(trunc(sysdate, 'yyyy'), 12) from dual ;
SYSDATE     ADD_MONTHS(
19-JUN-2006 01-JAN-2007
1 row selected.
SQL>2). for this also use the same expression that will evaluate to the january first of the year after that.

Similar Messages

  • Dbms_scheduler - dbms_aq - dbms_aqadm - event driven job runs only once/sec

    hi, i tried here to process events with 2 jobs... surprisingly i had to call dbms_lock.sleep(1) to be able to enqueue events
    at inserts in a row ... even more surprisingly the enqueuing doesn't function if the processing (prc_evsched) lasts some seconds...
    how must the code be changed to be able to enqueue all events after the inserts without any sleep()?
    and how must the code be changed to be able to enqueue all events with a proc (prc_evsched) running longer?
    thanx in advance for your help!
    --evsched
    h4.
    --to remove all test-objects
    h4.
    --test table
    h4.
    --define the object type to act as the payload for the queue
    h4.
    --creating the event queue
    h4.
    --creating the proc for the prog/job
    h4.
    --creating the proc for the prog/job
    h4.
    --creating the program
    h4.
    --creating the first job (for parallel execution)
    h4.
    --creating the second job (for parallel execution)
    h4.
    --test block
    h4.
    --test scenarios/results
    h4.
    --to remove all test-objects
    DECLARE
    exc_ora_27475 EXCEPTION; --ora-27475: <job_name> muss job sein
    PRAGMA EXCEPTION_INIT (exc_ora_27475, -27475);
    exc_ora_27476 EXCEPTION; --ora-27476: <program_name> ist nicht vorhanden
    PRAGMA EXCEPTION_INIT (exc_ora_27476, -27476);
    exc_ora_24010 EXCEPTION; --ORA-24010: QUEUE SYSGIS.EVENT_QUEUE ist nicht vorhanden
    PRAGMA EXCEPTION_INIT (exc_ora_24010, -24010);
    exc_ora_24002 EXCEPTION; --ORA-24002: QUEUE_TABLE SYSGIS.EVENT_QUEUE_TAB ist nicht vorhanden
    PRAGMA EXCEPTION_INIT (exc_ora_24002, -24002);
    exc_ora_4043 EXCEPTION; --ORA-04043: Objekt T_EVENT_QUEUE_PAYLOAD ist nicht vorhanden
    PRAGMA EXCEPTION_INIT (exc_ora_4043, -4043);
    exc_ora_942 EXCEPTION; --ORA-00942: Tabelle oder View nicht vorhanden
    PRAGMA EXCEPTION_INIT (exc_ora_942, -942);
    exc_ora_2289 EXCEPTION; --ORA-02289: Sequence ist nicht vorhanden.
    PRAGMA EXCEPTION_INIT (exc_ora_2289, -2289);
    v_fpos PLS_INTEGER := 1;
    BEGIN
    v_fpos := 10;
    BEGIN
    --remove job
    SYS.DBMS_SCHEDULER.DROP_JOB(job_name=> 'job_evsched', FORCE=>TRUE);
    EXCEPTION WHEN exc_ora_27475 THEN NULL;
    END;
    v_fpos := 12;
    BEGIN
    --remove job
    SYS.DBMS_SCHEDULER.DROP_JOB(job_name=> 'job_evsched_2', FORCE=>TRUE);
    EXCEPTION WHEN exc_ora_27475 THEN NULL;
    END;
    v_fpos := 20;
    BEGIN
    --remove program
    SYS.DBMS_SCHEDULER.DROP_PROGRAM(program_name=>'prg_evsched',FORCE=>TRUE);
    EXCEPTION WHEN exc_ora_27476 THEN NULL;
    END;
    v_fpos := 30;
    BEGIN
    -- stop the event queue.
    DBMS_AQADM.stop_queue (queue_name => 'evsched_event_queue');
    EXCEPTION WHEN exc_ora_24010 THEN NULL;
    END;
    v_fpos := 40;
    BEGIN
    -- drop the event queue.
    DBMS_AQADM.drop_queue (queue_name => 'evsched_event_queue');
    EXCEPTION WHEN exc_ora_24010 THEN NULL;
    END;
    v_fpos := 50;
    BEGIN
    -- Remove the queue table.
    DBMS_AQADM.drop_queue_table(queue_table => 'tab_evsched_event_queue');
    EXCEPTION WHEN exc_ora_24002 THEN NULL;
    END;
    v_fpos := 60;
    BEGIN
    -- remove type
    EXECUTE IMMEDIATE 'DROP TYPE typ_evsched_payload';
    EXCEPTION WHEN exc_ora_4043 THEN NULL;
    END;
    v_fpos := 70;
    BEGIN
    -- remove table
    EXECUTE IMMEDIATE 'DROP TABLE tab_evsched';
    EXCEPTION WHEN exc_ora_942 THEN NULL;
    END;
    v_fpos := 80;
    BEGIN
    -- remove sequence
    EXECUTE IMMEDIATE 'DROP SEQUENCE seq_evsched';
    EXCEPTION WHEN exc_ora_2289 THEN NULL;
    END;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('v_fpos='||v_fpos);
    END;
    h4.
    --test table
    CREATE TABLE tab_evsched
    ( id NUMBER
    , sys_date DATE
    , status VARCHAR2(1)
    , processed VARCHAR2(1) DEFAULT 'N'
    , processed_by varchar2(128)
    GRANT DELETE, INSERT, SELECT, UPDATE ON tab_evsched TO PUBLIC
    CREATE SEQUENCE seq_evsched
    h4.
    --define the object type to act as the payload for the queue
    CREATE OR REPLACE TYPE typ_evsched_payload AS OBJECT
    ( event_name VARCHAR2(30)
    , tab_evsched_id NUMBER
    , daterf DATE
    h4.
    --creating the event queue
    BEGIN
    -- Create a queue table to hold the event queue.
    DBMS_AQADM.create_queue_table
    ( queue_table => 'tab_evsched_event_queue'
    , queue_payload_type => 'typ_evsched_payload'
    , multiple_consumers => TRUE
    , COMMENT => 'Queue Table For Event Messages'
    -- Create the event queue.
    DBMS_AQADM.create_queue
    ( queue_name => 'evsched_event_queue'
    , queue_table => 'tab_evsched_event_queue'
    , queue_type => DBMS_AQADM.NORMAL_QUEUE
    , max_retries => 0
    , retry_delay => 0
    , dependency_tracking => FALSE
    , comment => 'Test Object Type Queue'
    , auto_commit => FALSE
    -- Start the event queue.
    DBMS_AQADM.start_queue
    ( queue_name => 'evsched_event_queue'
    END;
    h4.
    --creating the proc for the prog/job
    CREATE OR REPLACE PROCEDURE prc_evsched
    ( p_message IN typ_evsched_payload
    , p_job_name IN VARCHAR2
    IS
    BEGIN
    UPDATE tab_evsched
    SET processed = 'J'
    , processed_by = p_job_name
    , sys_date = p_message.daterf
    WHERE 1=1
    AND id = p_message.tab_evsched_id
    dbms_lock.sleep(5); --#sleep-1#
    COMMIT;
    END prc_evsched;
    h4.
    --creating the program
    DECLARE
    exc_ora_27476 EXCEPTION; --ora-27476: <program_name> ist nicht vorhanden
    PRAGMA EXCEPTION_INIT (exc_ora_27476, -27476);
    BEGIN
    BEGIN
    SYS.DBMS_SCHEDULER.DROP_PROGRAM(program_name=>'prg_evsched',FORCE=>TRUE);
    EXCEPTION
    WHEN exc_ora_27476 THEN
    NULL;
    END;
    SYS.DBMS_SCHEDULER.CREATE_PROGRAM
    ( program_name => 'prg_evsched'
    , program_type => 'STORED_PROCEDURE'
    , program_action => '"SYSGIS"."PRC_EVSCHED"'
    , number_of_arguments => 2
    , enabled => FALSE
    , comments => 'Program-Komponent für den Test von DBMS_SCHEDULER'
    --event message as the first param to prc_evsched 
    DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT
    ( program_name => 'prg_evsched'
    , argument_position => 1
    , metadata_attribute => 'EVENT_MESSAGE'
    --name of the job as the second param to prc_evsched 
    SYS.DBMS_SCHEDULER.define_program_argument
    ( program_name => 'prg_evsched'
    , argument_name => 'p_job_name'
    , argument_position => 2
    , argument_type => 'VARCHAR2'
    , default_value => 'dummy'
    --enable program   
    SYS.DBMS_SCHEDULER.ENABLE(NAME=>'prg_evsched');
    END;
    h4.
    --creating the first job (for parallel execution)
    DECLARE
    exc_ora_27475 EXCEPTION; --ora-27475: <job_name> muss job sein
    PRAGMA EXCEPTION_INIT (exc_ora_27475, -27475);
    BEGIN
    BEGIN
    --remove job
    SYS.DBMS_SCHEDULER.DROP_JOB(job_name=> 'job_evsched', FORCE=>TRUE);
    EXCEPTION WHEN exc_ora_27475 THEN NULL;
    END;
    DBMS_SCHEDULER.create_job
    ( job_name => 'job_evsched'
    , program_name => 'prg_evsched'
    , start_date => SYSTIMESTAMP
    , event_condition => 'tab.user_data.event_name = ''MYEVENT'''
    , queue_spec => 'evsched_event_queue'
    , auto_drop => FALSE
    , enabled => FALSE
    SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE
    ( job_name => 'job_evsched'
    , argument_name => 'p_job_name'
    , argument_value => 'job_evsched'
    SYS.DBMS_SCHEDULER.ENABLE(NAME=>'job_evsched');
    END;
    h4.
    --creating the second job (for parallel execution)
    DECLARE
    exc_ora_27475 EXCEPTION; --ora-27475: <job_name> muss job sein
    PRAGMA EXCEPTION_INIT (exc_ora_27475, -27475);
    BEGIN
    BEGIN
    --remove job
    SYS.DBMS_SCHEDULER.DROP_JOB(job_name=> 'job_evsched_2', FORCE=>TRUE);
    EXCEPTION WHEN exc_ora_27475 THEN NULL;
    END;
    DBMS_SCHEDULER.create_job
    ( job_name => 'job_evsched_2'
    , program_name => 'prg_evsched'
    , start_date => SYSTIMESTAMP
    , event_condition => 'tab.user_data.event_name = ''MYEVENT'''
    , queue_spec => 'evsched_event_queue'
    , auto_drop => FALSE
    , enabled => FALSE
    SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE
    ( job_name => 'job_evsched_2'
    , argument_name => 'p_job_name'
    , argument_value => 'job_evsched_2'
    SYS.DBMS_SCHEDULER.ENABLE(NAME=>'job_evsched_2');
    END;
    h4.
    --test block
    DECLARE
    PROCEDURE pr_ins_tab_evsched
    ( p_id IN NUMBER
    , p_status IN VARCHAR2
    IS
    BEGIN
    INSERT INTO tab_evsched(id,status) VALUES (p_id, p_status);
    COMMIT;
    --enqueue the MYEVENT-event
    IF p_status = 'M' THEN
    --enqueue works in 1sekunden-taktung.... !?
    dbms_lock.sleep(1); --#sleep-2#
    DECLARE
    v_enqueue_options DBMS_AQ.enqueue_options_t;
    v_message_properties DBMS_AQ.message_properties_t;
    v_message_handle RAW(16);
    v_queue_msg typ_evsched_payload;
    BEGIN
    v_queue_msg := typ_evsched_payload
    ( event_name => 'MYEVENT'
    , tab_evsched_id => p_id
    , daterf => SYSDATE
    v_enqueue_options.VISIBILITY := DBMS_AQ.ON_COMMIT;
    v_enqueue_options.delivery_mode := DBMS_AQ.PERSISTENT;
    v_message_properties.PRIORITY := 1;
    v_message_properties.DELAY := DBMS_AQ.NO_DELAY;
    v_message_properties.EXPIRATION := DBMS_AQ.NEVER;
    v_message_properties.CORRELATION := 'TEST MESSAGE';
    DBMS_AQ.enqueue
    ( queue_name => 'evsched_event_queue'
    , enqueue_options => v_enqueue_options
    , message_properties => v_message_properties
    , payload => v_queue_msg
    , msgid => v_message_handle
    END;
    END IF;
    COMMIT;
    END pr_ins_tab_evsched;
    BEGIN
    DELETE tab_evsched;
    pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
    pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
    pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
    pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
    pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
    pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
    pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
    pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
    END;
    SELECT * FROM tab_evsched ORDER BY id;
    SELECT * FROM sysgis.tab_evsched_event_queue;
    h4.
    --test scenarios/resultsh
    h5.
    --test results #sleep-1#=5, #sleep-2#=0
    --job (job_evsched) runs only once, only the first event is enqued/processed
    ID SYS_DATE STATUS PROCESSED PROCESSED_BY
    9 22.03.2012 17:00:41 M J job_evsched
    10 (Null) M N (Null)
    11 (Null) M N (Null)
    12 (Null) M N (Null)
    13 (Null) M N (Null)
    14 (Null) M N (Null)
    15 (Null) M N (Null)
    16 (Null) M N (Null)
    h5.
    --test results #sleep-1#=0, #sleep-2#=1
    --jobs (job_evsched/job_evsched2) run alternately, every events are enqued/processed
    ID SYS_DATE STATUS PROCESSED PROCESSED_BY
    25 22.03.2012 17:04:31 M J job_evsched_2
    26 22.03.2012 17:04:32 M J job_evsched_2
    27 22.03.2012 17:04:33 M J job_evsched
    28 22.03.2012 17:04:34 M J job_evsched_2
    29 22.03.2012 17:04:35 M J job_evsched_2
    30 22.03.2012 17:04:36 M J job_evsched_2
    31 22.03.2012 17:04:37 M J job_evsched
    32 22.03.2012 17:04:38 M J job_evsched_2
    h5.
    --test results #sleep-1#=5, #sleep-2#=1
    --jobs (job_evsched/job_evsched2) run alternately, only two events are enqued/processed
    ID SYS_DATE STATUS PROCESSED PROCESSED_BY
    41 22.03.2012 17:07:42 M J job_evsched_2
    42 (Null) M N (Null)
    43 (Null) M N (Null)
    44 (Null) M N (Null)
    45 (Null) M N (Null)
    46 (Null) M N (Null)
    47 22.03.2012 17:07:48 M J job_evsched
    48 (Null) M N (Null)
    */

    hi, thank you for your (fast) answer! that is the solution to my problem!
    now i have a follow-up question:
    i've got a procedure, that runs between 1 and 2 minutes long. unlimited running lightweight jobs
    would freeze the db...
    how can the count of the parallel running lightweight-jobs be limited?
    according to the documentation it is not possible:
    There is no explicit limit to the number of lightweight jobs that can run simultaneously to process multiple instances of the event.
    However, limitations may be imposed by available system resources.
    could you explain to me, what it (...available system recources...) means?
    eventually what i would like to have: max. two parallel running (lightweight) jobs....
    thank you in advance, bye, á
    ps: can i attach a file to the post anyway?
    Edited by: user4786904 on 23.03.2012 07:22

  • How do I submit a job to run only once?

    I have a stored procedure that submits a job. If this job fails, I don't want it to continue trying to run. Does anyone know how to ensure that it will only run once, no matter what?
    I did try something similar to the following:
    procedure proc_submitted_as_job(p_job_no number) is
    begin
    dbms_job.broken(p_job_no, true);
    end;
    However, I found out that if you change the Broken state while a job is running, then it gets reset when the job completes.
    Basically, I'm using the dbms_job utility to run a long-running procedure in the background. If there's another way to obtain this same result, I'd love to hear it.

    I am still haveing problems so I will try and attach my program and see if you can help a little more that. It will probably be easier for you to look at this way. When you look at the diagram sequence 0 is the one the problem is in. In that sequence you will see a case structure and that is where the finite pulse train vi is. When case 1 is selected the finite pulse train will run again and again until I leave case 1. I need to have the program run the finite pulse train once and then wait and do nothing until the case is changed. The finite pulse train will be in all cases inside the case structure I just haven't done that yet, I am waiting until it works. The pulse train is used to move a stepper motor that is why running only once is im
    portant because the stepper motor is used to position something.
    Attachments:
    AMC_Eagle_Both_Inputs_Working_2.vi ‏266 KB

  • How do I get a case to run only once

    I am using an e-series DAQ board to bring a pwm signal, then I use labview to use that signal to pick one of three cases. depending on the case picked a finite pulse stream is sent out. Currently the finite pulse vi keeps repeating because the the program stays in the case. I need a way to get labview to run the finite pulse output only once, and not run again until a new case is picked. I don't have the case in a while loop.
    Thanks For The Help

    I am still haveing problems so I will try and attach my program and see if you can help a little more that. It will probably be easier for you to look at this way. When you look at the diagram sequence 0 is the one the problem is in. In that sequence you will see a case structure and that is where the finite pulse train vi is. When case 1 is selected the finite pulse train will run again and again until I leave case 1. I need to have the program run the finite pulse train once and then wait and do nothing until the case is changed. The finite pulse train will be in all cases inside the case structure I just haven't done that yet, I am waiting until it works. The pulse train is used to move a stepper motor that is why running only once is im
    portant because the stepper motor is used to position something.
    Attachments:
    AMC_Eagle_Both_Inputs_Working_2.vi ‏266 KB

  • How to get lauchctl daemons/agents to run only once a day

    How do you get a daemons/agents to run only once a day regardless of the error code of the .sh you are running?
    (not I'm not looking for run once or run on reboot. I want a job to run at 3am every day and it has several bash commands in it. Regardless of the returns by any of the commands in the script, I only want this to run once - NO RESPAWN).

    Ok still not working.. here is the plist
    the .sh file does file processing and then uploads xml files to my server and should run once a day. Here I have it running at 11:45am. It completes and then runs again and again and again.
    The plist is placed in LaunchAgents and loaded with $launchctl load com.iclassicnu.crontabtest.plist
    ideas?
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>label</key>
    <string>com.iclassicnu.crontabtest</string>
    <key>ProgramArguments</key>
    <array>
    <string>/Users/dan/Desktop/iClassicNu/Idea/Forexite/ForexUpdate.sh</string>
    </array>
    <key>WorkingDirectory</key>
    <string>/Users/dan/Desktop/iClassicNu/Idea/Forexite</string>
    <key>OnDemand</key>
    <false/>
    <key>Nice</key>
    <integer>1</integer>
    <key>StartCalendarInterval</key>
    <dict>
    <key>Hour</key>
    <integer>11</integer>
    <key>Minute</key>
    <integer>45</integer>
    </dict>
    <key>StandardErrorPath</key>
    <string>/Users/dan/tmp/icnTest1.err</string>
    <key>StandardOutPath</key>
    <string>/Users/dan/tmp/icnTest1.out</string>
    </dict>
    </plist>

  • Fast refresh of "materialized view with joins only"

    Hi,
    My Requirement:
    I need to create a materialized view joining two tables.
    Table1 -> Does not have primary key
    Table2 -> Has a primary key
    I need to refesh the mat view only when DML commands are done on Table1 alone.
    And it will be better if i have a Refresh on commit rather on demand.
    The following code is what i used and it dint work for me:
    CREATE MATERIALIZED VIEW LOG ON Table1 WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON Table2;
    CREATE MATERIALIZED VIEW AAYT_ETF
    REFRESH FORCE ON COMMIT
    ENABLE QUERY REWRITE
    AS
    SELECT A.rowid "table1_rowid", A.ACCTNUM, A.CORR_NUM, A.OFC_NUM, A.RR_NUM, A.BUY_SELL_CDE, A.ACT_AMT, A.CSP_SYM, A.SECR_DESC, A.ACT_QTY
    FROM Table1 A, Table2 G WHERE
    A.CSP_NUM = G.CSP_NUM AND
    G.ASST_SUB_STYP = 'ETF';
    Issue Faced: In this case the refresh happends even while i do DML on Table2.
    But i need the refresh only when i do DML on Table1. I also unable to create Refresh Fast Mat view.
    Can anyone please tell me how to create the Materialized view Log and the Materialized view. Thanks in advance.

    This forum only is for questions relating to the use of OLAP Option. I would post your question on the database forum.
    Keith Laker
    Oracle Data Warehouse Product Management
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • Using an NDS statement for a SQL stament run only once in a proceudure

    Hi,
    We're using Oracle 11.1.0.7.0.
    I'm going through code written by someone else. In this package they're using NDS for every SQL call whether it gets called multiple times or just once. Is that a good thing?
    I thought NDS was only reserved for SQL statements that get called over and over again in a procedure with possible varying 'WHERE clause' variables and so on...
    Is there ANY benefit to using NDS for SQL queries called only once in a procedure?
    Thanks

    There is no benefit unless you want to turn PL/SQL into SQL*Plus (parse once, run once)
    Procedures exist to make sure : parse at compile time, run many times.
    The code is shooting itself in its own foot.
    Or the developer must have got hold of Tom Kyte's unpublished one chapter book 'How to write unscalable applications'.
    Sybrand Bakker
    Senior Oracle DBA

  • Help: I want to auto schedule a load using file watcher but it runs only once for the first time and after that it is not running at all

    Hi All,
    I am trying  to execute the below code as provided from one of the blogs. i am able to run the job only once based on a file watcher object(i.e. for very first time) and after that the job is not running at all and if  i schedule the job to run automatically based on interval of 10 or more minutes it is executing properly). Please let me know or guide me if i have missed any step or configuration.that is needed.
    Version of Oracle 11.2.0.1.0
    OS : Windows 7 Prof
    Given all the necessary privileges
    BEGIN
      DBMS_SCHEDULER.CREATE_CREDENTIAL(
         credential_name => 'cred',
         username        => 'XXXX',
         password        => 'XXXX');
    END;
    CREATE TABLE ZZZZ (WHEN timestamp, file_name varchar2(100),
       file_size number, processed char(1));
    CREATE OR REPLACE PROCEDURE YYYY
      (payload IN sys.scheduler_filewatcher_result) AS
    BEGIN
      INSERT INTO ZZZZ VALUES
         (payload.file_timestamp,
          payload.directory_path || '/' || payload.actual_file_name,
          payload.file_size,
          'N');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_PROGRAM(
        program_name        => 'prog1',
        program_type        => 'stored_procedure',
        program_action      => 'YYYY',
        number_of_arguments => 1,
        enabled             => FALSE);
      DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT(
        program_name        => 'prog1',
        metadata_attribute  => 'event_message',
        argument_position   => 1);
      DBMS_SCHEDULER.ENABLE('prog1');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_FILE_WATCHER(
        file_watcher_name => 'file_watcher1',
        directory_path    => 'D:\AAAA',
        file_name         => '*.txt',
        credential_name   => 'cred',
        destination       => NULL,
        enabled           => FALSE);
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_JOB(
        job_name        => 'job1',
        program_name    => 'prog1',
        queue_spec      => 'file_watcher1',
        auto_drop       => FALSE,
        enabled         => FALSE);
      DBMS_SCHEDULER.SET_ATTRIBUTE('job1','PARALLEL_INSTANCES',TRUE);
    END;
    EXEC DBMS_SCHEDULER.ENABLE('file_watcher1,job1');
    Regards,
    kumar.

    Please post a copy and paste of a complete run of a test case, similar to what I have shown below.
    SCOTT@orcl12c> SELECT banner FROM v$version
      2  /
    BANNER
    Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
    PL/SQL Release 12.1.0.1.0 - Production
    CORE    12.1.0.1.0    Production
    TNS for 64-bit Windows: Version 12.1.0.1.0 - Production
    NLSRTL Version 12.1.0.1.0 - Production
    5 rows selected.
    SCOTT@orcl12c> CONN / AS SYSDBA
    Connected.
    SYS@orcl12c> -- set file watcher interval to one minute:
    SYS@orcl12c> BEGIN
      2    DBMS_SCHEDULER.SET_ATTRIBUTE
      3       ('file_watcher_schedule',
      4        'repeat_interval',
      5        'freq=minutely; interval=1');
      6  END;
      7  /
    PL/SQL procedure successfully completed.
    SYS@orcl12c> CONNECT scott/tiger
    Connected.
    SCOTT@orcl12c> BEGIN
      2    -- create credential using operating system user and password (fill in your own):
      3    DBMS_SCHEDULER.CREATE_CREDENTIAL
      4       (credential_name     => 'cred',
      5        username          => '...',
      6        password          => '...');
      7  END;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- create table to insert results into:
    SCOTT@orcl12c> CREATE TABLE ZZZZ
      2    (WHEN      timestamp,
      3      file_name varchar2(100),
      4      file_size number,
      5      processed char(1))
      6  /
    Table created.
    SCOTT@orcl12c> -- create procedure to insert results:
    SCOTT@orcl12c> CREATE OR REPLACE PROCEDURE YYYY
      2    (payload IN sys.scheduler_filewatcher_result)
      3  AS
      4  BEGIN
      5    INSERT INTO ZZZZ VALUES
      6        (payload.file_timestamp,
      7         payload.directory_path || '/' || payload.actual_file_name,
      8         payload.file_size,
      9         'N');
    10  END;
    11  /
    Procedure created.
    SCOTT@orcl12c> -- create program, define metadata, and enable:
    SCOTT@orcl12c> BEGIN
      2    DBMS_SCHEDULER.CREATE_PROGRAM
      3       (program_name          => 'prog1',
      4        program_type          => 'stored_procedure',
      5        program_action      => 'YYYY',
      6        number_of_arguments => 1,
      7        enabled          => FALSE);
      8    DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT(
      9       program_name         => 'prog1',
    10       metadata_attribute  => 'event_message',
    11       argument_position   => 1);
    12    DBMS_SCHEDULER.ENABLE ('prog1');
    13  END;
    14  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> BEGIN
      2    -- create file watcher:
      3    DBMS_SCHEDULER.CREATE_FILE_WATCHER
      4       (file_watcher_name   => 'file_watcher1',
      5        directory_path      => 'c:\my_oracle_files',
      6        file_name          => 'f*.txt',
      7        credential_name     => 'cred',
      8        destination          => NULL,
      9        enabled          => FALSE);
    10  END;
    11  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> BEGIN
      2    -- create job:
      3    DBMS_SCHEDULER.CREATE_JOB
      4       (job_name          => 'job1',
      5        program_name          => 'prog1',
      6        queue_spec          => 'file_watcher1',
      7        auto_drop          => FALSE,
      8        enabled          => FALSE);
      9    -- set attributes:
    10    DBMS_SCHEDULER.SET_ATTRIBUTE ('job1', 'PARALLEL_INSTANCES', TRUE);
    11  END;
    12  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- enable:
    SCOTT@orcl12c> EXEC DBMS_SCHEDULER.enable ('file_watcher1, job1');
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- write file (file must not exist previously):
    SCOTT@orcl12c> CREATE OR REPLACE DIRECTORY upncommon_dir AS 'c:\my_oracle_files'
      2  /
    Directory created.
    SCOTT@orcl12c> declare
      2    filtyp utl_file.file_type;
      3  begin
      4    filtyp := utl_file.fopen ('UPNCOMMON_DIR', 'file1.txt', 'W', NULL);
      5    utl_file.put_line (filtyp, 'File has arrived ' || SYSTIMESTAMP, TRUE);
      6    utl_file.fclose (filtyp);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- wait long enough (may take more than one minute) for job to run:
    SCOTT@orcl12c> EXEC DBMS_LOCK.SLEEP (100)
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- check for results:
    SCOTT@orcl12c> SELECT * FROM zzzz
      2  /
    WHEN
    FILE_NAME
    FILE_SIZE P
    22-OCT-13 10.12.28.309000 PM
    c:\my_oracle_files/file1.txt
            57 N
    1 row selected.
    SCOTT@orcl12c> declare
      2    filtyp utl_file.file_type;
      3  begin
      4    filtyp := utl_file.fopen ('UPNCOMMON_DIR', 'file2.txt', 'W', NULL);
      5    utl_file.put_line (filtyp, 'File has arrived ' || SYSTIMESTAMP, TRUE);
      6    utl_file.fclose (filtyp);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- wait long enough (may take more than one minute) for job to run:
    SCOTT@orcl12c> EXEC DBMS_LOCK.SLEEP (100)
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- check for results:
    SCOTT@orcl12c> SELECT * FROM zzzz
      2  /
    WHEN
    FILE_NAME
    FILE_SIZE P
    22-OCT-13 10.12.28.309000 PM
    c:\my_oracle_files/file1.txt
            57 N
    22-OCT-13 10.14.08.580000 PM
    c:\my_oracle_files/file2.txt
            57 N
    2 rows selected.

  • Mass activity running only once for custom parallel object

    Hi
    I have created custom parallel object EXT_UI and created mass activity for this but the report in triggered only once and not going for second interval .
    Can any one help me out in this.
    Thanks in advance.
    Chetan
    Message was edited by: CHETAN N P
    Mass activity is running fine for standard object ANLAGE but not for custom one
    Please share me steps to be followed in creating custom parallel object.
    Regards,
    Chetan

    Hi Chetan,
    I think you need to make changes in the Events which gets triggered by the mass activity.
    Can you let me know the mass transaction code for which you have customised the activity,
    Thanks,
    Amlan

  • Materialized view process running constantly /* MV_REFRESH (DEL) */

    Hello,
    3 days ago I created this Materialized view:
    CREATE MATERIALIZED VIEW src_mv
    nologging
    compress
    partition by range (dato)
    partition src_mv_pre2005 values less than (to_date('2005-01-01','yyyy-mm-dd'))
    , partition src_mv_2005 values less than (to_date('2006-01-01','yyyy-mm-dd'))
    , partition src_mv_2006 values less than (to_date('2007-01-01','yyyy-mm-dd'))
    , partition src_mv_2007 values less than (to_date('2008-01-01','yyyy-mm-dd'))
    , partition src_mv_2008 values less than (to_date('2009-01-01','yyyy-mm-dd'))
    , partition src_mv_2009 values less than (to_date('2010-01-01','yyyy-mm-dd'))
    , partition src_mv_2010 values less than (to_date('2011-01-01','yyyy-mm-dd'))
    , partition src_mv_2011 values less than (to_date('2012-01-01','yyyy-mm-dd'))
    , partition src_mv_2012 values less than (to_date('2013-01-01','yyyy-mm-dd'))
    , partition src_mv_2013 values less than (to_date('2014-01-01','yyyy-mm-dd'))
    REFRESH on demand
    start with sysdate next trunc(sysdate)+1+3.75/24
    with primary key
    ENABLE QUERY REWRITE
    AS
    SELECT srcid
    , a
    , dato
    , group
    , COUNT(*) tx
    , SUM(amount) sumtx
    FROM b btx
    JOIN groups g USING(gid)
    join c on (srcid=cid and ctype='W')
    GROUP BY srcid
    , a
    , dato
    , group;
    Table b has more than 330 millions rows and table c has about 3 millions rows. However the creation of the MV itself tok about an hour.
    After the MV was created I tried to create an index on dato but I got:
    ORA-00054: resource busy and acquire with NOWAIT specified
    When I checked the active sessions, I see this:
    /* MV_REFRESH (DEL) */ delete from "X"." SRC_MV"
    So, now I am not able to create any index, drop the MV or even kill the session that is running the /* MV_REFRESH (DEL) */.
    Why is this DELETE statement running, when I said REFRESH on demand? Is this running since the MV was created?
    On the other hand, the database is shutdown/startup everyday at 8pm/10pm, and there has not been any problem with this shutdown/startup, so I can't understand why this Delete statement is still running.
    The MV has now a compilation error status, why is not possible to drop it then?
    Can anybody help me?
    Thanks in advance,
    Alida

    When I try to kill the session I get this:
    Error starting at line 1 in command:
    alter system kill session '261,1408'
    Error report:
    SQL Error: ORA-00031: session marked for kill
    00031. 00000 - "session marked for kill"
    *Cause:    The session specified in an ALTER SYSTEM KILL SESSION command
    cannot be killed immediately (because it is rolling back or blocked
    on a network operation), but it has been marked for kill. This
    means it will be killed as soon as possible after its current
    uninterruptable operation is done.
    *Action:   No action is required for the session to be killed, but further
    executions of the ALTER SYSTEM KILL SESSION command on this session
    may cause the session to be killed sooner.
    Every time I run the command to kill the session and apears again the next day :\
    Thanks,
    Alida

  • Run only once in case structure

    Hello,
    I have a menu set up that is wired to a case structure.  Of course the menu is some boolean buttons that are set to switch when pressed so the case will stay open as long as the button is true.
    inside that case I have another menu and a case structure that operates the same.  In one of these cases I have a piece of code that I only want to run once.  I have tried the while loop that runs once and a for loop that only runs once, but the section of code seems to run continuosly instead of just once.  It works ok if I use any of the latch functions but not the switch when pressed functions.  However, I need the button to stay pressed until the user is finished with that case.
    I really don't want to use an event structure as I was saving that for another piece of code that monitors inputs.
    Anyone have a suggestion?

    Typically, this works easiest with a shift register and and a boolean "implies" function.
    In the code example (see image), the button is set to "switch until released". (Of course you probably don't need the NOT, simply place your one-time code into the FALSE case )
    Message Edited by altenbach on 01-26-2007 01:52 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    implies.png ‏8 KB

  • How to make the concurrent request set run only once

    Hi Team,
    Ijust have a requirement.
    At a time only single concurrent request set should be running and the remaining submitted request sets should be in pending status.
    I mean to say : i have a concurrent request set : "Invoice Req Set"
    If user submits the request set multiple times: Invoice Req Set once
    the second one should not be running until the first request set : "Invoice Req Set" completes.
    Any suggestions ??
    -Sridhar

    Hi;
    Please check below which could be helpful for your issue:
    how to prevent multiple request of one conc program
    Regard
    Helios

  • Xcelsius runs only once, then the "play=true" needs to be reset.

    Post Author: stephantmi
    CA Forum: Xcelsius and Live Office
    When I export into PowerPoint the dashboard will only run one time... I then need to goto properties and find "play" and change from "false" to "true". I found a website that stated "Note: we've recently discovered that if the flash movie is scripted to stop
      playing rather than loop or repeat then this command appears to be passed to
      PowerPoint - this results in the play command being reset to false. The simple
      solution (if you've got the source flash file) is to remove the offending command,
      alternatively you'll have to save the presentation with play set to true and
      not run it again until ready to present - it'll only run once and will need
      resetting before it'll work again!" How do I send out a PowerPoint that would allow the person I would email the presentation to run the slide show and interact with the dashboard if it doesn't initiate without manual intervention.

    Post Author: abrat
    CA Forum: Xcelsius and Live Office
    I assume this is with X2008?   BTW. Right-clicking on the flash and choosing 'play' should also work. This is an Adobe issue. They have increased the security on the use of flash files.  They are afraid of malicious use and viruses so they now require manual intervention.  You could contact Adobe and let them know how this security feature is affecting you. Xcelsius is also currently in talks with them. - Andy

  • Scheduling a filter to run only once a day

    Hi All,
    I am trying to build a filter running once every day, so far i am using "scheduledSystemEvent" which executes the filter every 5 mins.
    I tried doing this via "CustomScheduleEvnet" also but did not have any luck with it.
    Following is the snap shot of the table that i am mergin with the IdcScheduledSystemEvents
    &lt;td&gt;CustomDailyEvent&lt;/td&gt;
    &lt;td&gt;CustomDailyEventInterval&lt;/td&gt;
    &lt;td&gt;&lt;$include dailyEvent$&gt;&lt;/td&gt;
    &lt;td&gt;inDays&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;ScheduledWork&lt;/td&gt;
    Your any pointers will be hightly appriciated.
    many thanks,
    sapan

    Hey sapan,
    The quick and dirty way I've done this before is with a java filter hooked into "checkScheduledEvents" (emphasis on "quick and dirty"). Example below:
         public int doFilter(Workspace ws, DataBinder binder, ExecutionContext cxt)
                   throws DataException, ServiceException
              try
                   //sleep to make sure the server is completely initialized
                   Thread.sleep(30000);
              catch(Exception e)
              //get last time the filter was run
              String lastRunString = SharedObjects.getEnvironmentValue("customProccessLastRunTime");
              long lastRunMillis = 0;
              //handle case were the server has been restarted and the environment value is empty
              if(lastRunString != null && lastRunString.length() > 0)
                   lastRunMillis = Long.parseLong(lastRunString);     
              //if it has been a day since the last check,
              //run the queries to check that the contract files have their workflow flag synced
              Date now = new Date();
              long nowMillis = now.getTime();
              if((nowMillis - lastRunMillis) > 86400000)
    //do daily processing here
                   //update last run time
                   SharedObjects.putEnvironmentValue("customProccessLastRunTime", ""+nowMillis);
    Hope that helps,
    Andy Weaver - Software Consultant
    Fishbowl Solutions < http://www.fishbowlsolutions.com?WT.mc_id=L_Oracle_Consulting_amw >

  • Abap report need to run only once in a day

    can i restrict my abap report that it should run once in a day. is there any authorization funda? or any sap provided concept? how can i approach this?

    hi,
    no authorizations for tht if u want try this code i think it will help u
    DATA:count,date LIKE sy-datum.
    GET PARAMETER ID 'MAX' field count.
    GET PARAMETER ID 'DAT' FIELD date.
    IF date is initial.
    date = sy-datum.
    ENDIF.
    IF date = sy-datum.
    count = count + 1.
    else.
    message e000(zmsgtab)."u con't execute it more than once in a day.
    endif.
    set PARAMETER ID 'MAX' field count.
    IF count > 5.
    count = 0.
    set PARAMETER ID 'MAX' field count.
    date = date + 1.
    set PARAMETER ID 'DAT' field date.
    message e000(zmsgtab)."u con't execute it more than once in a day.
    ENDIF.
    write:/ 'this is my program'.
    <b><removed_by_moderator></b>
    <b><removed_by_moderator></b>
    feel free to ask any quiries
    <b><removed_by_moderator></b>
    <b><removed_by_moderator></b>

Maybe you are looking for