Job on database event

Hi all,
I want to create a job based on a database event.
I want to delete records in a table that are older then for example 4 years old. Tha tabel has a create_date attribute.
Is this possible?
Ps.
Currently I would create a procedure that would check for records older than 4 years and delete them. I would then create a job that runs this procedure every year.
And then I read about jobs based on events. they work with the concept of oracle messaging and queues. This seemd a better idea.

Hi,
I don't think events would work well for your case. Database events are really AQ messages. The database really doesn't send messages, you need to create the infrastructure to enqueue messages or raise alerts yourself.
In my opinion, building the infrastructure to do this is less efficient and more complex than simply scheduling a job that runs once every so often.
-Ravi

Similar Messages

  • How to Schedule Job using Database Control for SQLPLUS script?

    Hi All,
    I am using Database version 10.2. I would like to schedule a SQLPLUS script job using Database control (Not using Grid Control!). The following is the script.
    ========================================================
    define OEM_FRIENDLY=1
    define OWB_BACKGROUND=0
    set serveroutput on
    set verify off
    whenever sqlerror exit failure;
    define REPOS_OWNER='&1.'
    define LOCATION_NAME='&2.'
    define TASK_TYPE='&3.'
    define TASK_NAME='&4.'
    define SYSTEM_PARAMS='&5.'
    define CUSTOM_PARAMS='&6.'
    alter session set current_schema = &REPOS_OWNER.;
    set role owb_d_&REPOS_OWNER., owb_o_&REPOS_OWNER.;
    variable exec_return_code number;
    begin
    -- Initialize Return Code
    :exec_return_code := wb_rt_api_exec.RESULT_FAILURE;
    -- Run Task
    :exec_return_code := wb_rt_api_exec.run_task('&LOCATION_NAME.',
    '&TASK_TYPE.',
    '&TASK_NAME.',
    '&CUSTOM_PARAMS.',
    '&SYSTEM_PARAMS.',
    &OEM_FRIENDLY.,
    &OWB_BACKGROUND.);
    end;
    exit :exec_return_code;
    ===========================================================
    Is it possible to schedule SQLPLUS script with 6 different parameters? If yes then how can I schedule for monday to friday or only for Saturday and sundays.
    Please provide brief steps.
    Thanks for your help in advance.
    - Mehul

    Let me explain to you about scheduler.
    You can schedule a pl/sql stored procedure TEST_S as follows...
    Begin
    dbms_scheduler.create_job(
    job_name=>'MY_JOB',
    Job_Type=>'STORED_PROCEDURE',
    job_action=>'TEST_S',
    start_date=>sysdate,
    repeat_interval=>'freq=monthly;BYDAY=MON,TUE,WED,THU,FRI',
    end_date=>null');
    END;
    You can also also execute o/s script like .bat or .sh. For this job type should be EXECUTABLE.
    Example of converting a .sql script in .bat script...
    insert.sql
    insert into dept values(50,'IT','LONDON');
    exit
    insert.bat
    sqlplus scott/tiger @insert.sql
    Executing now...
    C:\Documents and Settings>insert.bat
    C:\Documents and Settings>sqlplus scott/tiger @insert.sql
    SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 1 08:01:00 2007
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    1 row created.
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - P
    oduction
    With the Partitioning, OLAP and Data Mining options
    C:\Documents and Settings>
    So first read about DBMS_SCHEDULER and do the work in prompt. Then you can go and schedule it even by database control.
    Scheduling by database control...
    http://www.oracle.com/technology/oramag/oracle/04-jul/o44tech_dba.html
    Scheduler
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#CIHEHDHA
    PS: By default each job you created is disable state. Please enable it by enable procedure of DBMS_SCHEDULER package.

  • How to schedule a background Job based on events

    Hi,
    We are on 4.6 C.
    We have a background job that has two ABAP programs.
    We need to start the 2nd ABAP program only after the first one has run successfully.
    If the second ABAP program does not run, the the job should have a status "FINISHED".
    Help appreciated.
    Thanks
    Mala

    Hi,
    How to schedule a background Job based on events,please refer to the follow SAP help:
    You can use events that have already been defined, or you can create new events for scheduling background jobs.
    If you wish to use new events, do the following to implement the event scheduling:
    Define and transport the event as a user event with transaction SM62.
    You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.
    If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.
    Do this to transport an event:
    Create a transport request.
    Start the editor in the transport request and enter the following:
    R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.
    Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event ID’s that you have created.
    Save and release the transport request. Ensure that it is imported into your production system(s).
    To trigger an event, add:
    – the function module BP_EVENT_RAISE to your ABAP program, or
    – the program SAPEVT to your external script, batch file, or program.
    When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.
    Schedule the jobs that are to run when your events are triggered.
    You can schedule jobs for one-time start or to be started whenever an event is triggered.
    Regards,
    collysun

  • Error saving job  to database for standard jobs scheduling

    Hi,
        In IDES server when iam goto Tr.code -- SM36 -- Standard Jobs -- Default Scheduling iam getting below error.
    Error saving job  to database
    Message no. BT117
    Diagnosis
    The SAP system was unable to save the current job in the database. This failure suggests that there is a problem with the database system or with the network connections between the SAP application servers and the database system.
    System Response
    Job not saved and not scheduled.
    Procedure
    To analyze this problem, start by checking the system log for messages about network or database problems.  You can also use the computing center management system to check your system for problems.
    Guide me for the same.
    Thanku

    HI,
    Sometimes this error will come.
    Try to schedule jobs manually using SM36 instead of using standard job button.
    Also you can check this thread
    Re: Error saving job SAP_REORG_JOBS to database
    Which seems to report same problem.
    Its nothing to take with database conenctivity as SAP is up and running .
    Try this and revert.
    Regards,

  • How to generate an email on a database event?

    Dear gurus...I've heard about diferent ways of generating email in response to a database event e.g
    1 - Using UTL_MAIL package
    or
    2 - Event Driven Reporting feature of 10g Database and using SRW.Run_Report package to generate and mail a report.
    Now I'm confused that how should I accomplish the following tasks:
    (i) - How to generate an email after Insert/Update/Delete on a table and acknowledge the concerned users about that event?
    (ii) - How to attach a text file with that email?

    Dear Ivan...I've tried both UTL_SMTP and UTL_MAIL, UTL_SMTP is working well and sending mails but following code of UTL_MAIL is giving the error which I can't guess, why?
    DECLARE
    CRLF CHAR(2) := CHR(10) || CHR(13);
    BEGIN
    UTL_MAIL.SEND(sender => '[email protected]',
    recipients => '[email protected]',
    cc => NULL,
    bcc => NULL,
    subject => 'Test Email',
    message => 'Test line1' || CRLF || CRLF || 'Test line2',
    mime_type => 'text/plain; charset=us-ascii',
    priority => 1);
    END;
    and the error is:
    ORA-29279: SMTP permanent error: 554 Message is not RFC compliant
    ORA-06512: at "SYS.UTL_SMTP", line 20
    ORA-06512: at "SYS.UTL_SMTP", line 98
    ORA-06512: at "SYS.UTL_SMTP", line 345
    ORA-06512: at "SYS.UTL_MAIL", line 577
    ORA-06512: at "SYS.UTL_MAIL", line 594
    ORA-06512: at line 4
    could u guess why this error is generating???
    P.S...I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production on MS-Windows Server-2003.

  • Trigger a job using an event through a process chain

    Hi,
    After the success of 5metachain, I am using AND condition
    My requirement is as follows, it should trigger a job which needs to be after AND condition,
    I have created an event using sm64. Basically the client wants to trigger the job using the event through the process chain. I have tried test scenariou2019s using ABAP program (Process type) in the process chain but it is failing. Is there any other way to trigger a job using an event through a process chain? If ABAP program is the only option, can you please specify what all needs to be filled in the variant?
    Regards.
    Jerry

    Hi,
    Create a program like below,
    CALL FUNCTION 'BP_EVENT_RAISE'
      EXPORTING
        EVENTID = 'EVENT WHICH YOU HAVE CREATED'
    EXCEPTIONS
       BAD_EVENTID                  = 1
       EVENTID_DOES_NOT_EXIST       = 2
       EVENTID_MISSING              = 3
       RAISE_FAILED                 = 4
       OTHERS                       = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    search and include the program name which you have created above in the "ABAP program" process type which you are going to include in the process chain.
    Include the event which you have created in the start condition of the job.
    Note: No need of give any variant, because here we are calling only one function in this program.
    Regards,
    Sridevi.

  • SQL Server Agent Job And Database Mail - Error formatting query, probably invalid paramters

    We have a stored procedure that we are trying to call with a SQL Server Agent Job. The stored procedure calls Database Mail. This is SQL 2008. The execute task is simply:
    USE [Production]
    GO
    EXEC [dbo].[JOB_EMAIL_SCHEDULED_REPORTS]
    GO
    When the job runs, it is erroring out immediately, with the error:
    Execute as user: NT AUTHORITY\NETWORK SERVICE. Error formatting query, probably invalid paramters [SQLSTATE 42000] (Error 22050). The step failed.
    When we go into SQL Server Manager and just execute the SQL query, it works though. Something within the SQL Server Agent job,  and Database Mail is causing problems. Any ideas? Thanks.

    Justin,
    If you use SSMS then the procedure is executed under a different user when compared to running using a SQL Server Agent Job.
    Isolate the problem by running a SQL Server agent job that sends a mail. Also check if the NT Authority\Network Service account is
    in good standing. Look at the below thread with a similar problem that had an expired account.
    http://social.msdn.microsoft.com/Forums/en/sqltools/thread/bac7ecee-a156-4313-b532-ba15813a0700
    http://SankarReddy.com/

  • Ingres to Oracle Migration (Database Events)

    I am currently working on an Ingres II to Oracle 8.1.6 migration
    project. The client OpenROAD 3.5/03 application makes extensive
    use of Ingres database events.
    Put simply we have a single master process which services
    requests for orders from a number of child processes. There is a
    desire to minimise the degree of code changes when migrating the
    application. OpenROAD provides the
    DBSessionObject.RegisterDBEvent and RaiseDBEvent methods which
    make underlying calls to the Oracle DBMS_ALERT package.
    The problem we have stems from the fact that Ingres database
    events are broadcast to all sessions registered as having an
    interest, much like the Oracle alerts. However, Ingres events
    are retained in a queue whereas the Oracle alert messages, if
    unread, are simply overwritten.
    I feel the best solution would probably be to use the Oracle
    DBMS_PIPE package and build dedicated pipes between each
    master/child session. However, OpenROAD does not appear to
    provide an interface to this package.
    Does anyone have experience of this problem or have any
    suggestions? I'm looking for information on how other sites have
    successfully migrated between the two products. I did find a
    migration toolkit but it seems to avoid the issue of database
    events.
    Many thanks,
    Max

    hello,
    I am interested on the architecture which you set up to see how
    you reach a base ORACLE from OPENROAD or ABF applications. Have
    you planned to pass in OPENROAD 4.1? do you know the GATEWAY CA?
    Thanks in advance,
    Didier

  • Second opinion : Database events

    I'm probably a bit late but I found Database events and that seems to me something I have to use... Together with SQLlite / applescript...
    But I want a second opinion. Is this is the best way to store my data for free?
    Because when I start using database events I will get big databases with many records and fields,...
    Of course if you have a better suggestion I would like to know it..
    I prefer free / open source solutions. My software budget is zero this year.
    Many thanks.

    What is your primary goal here - to store lots of data, or to AppleScript your data?
    The reason I ask is that Database Events is your simplest path to using a database within AppleScript, however it has a few caveats.
    First is that I don't know anyone that's using it at scale. I've used it myself for small data sets but I don't know anyone storing gigabytes (or terabytes) of data with it. It might be fine - I just don't hear of it happening.
    The second is that, IIRC, Apple have changed their underlying database in the past, so you may need to consider what to do if they repeat that (and whether they'll provide seamless migration tools).
    So if your primary goal is to store lots of data, then there are other, free, solutions out there including MySQL, PostgreSQL and more. Of course, the downside to these is that there is little or no AppleScript integration, so you're limited to interacting with then via shell commands. AFAIK all the other databases that support AppleScript (either directly or via ODBC) are commercial.

  • Database events

    Hi I am connecting to Oracle 9 database using OracleInProcServer library from my .NET 1.1 project.
    I want to use database events so Oracle can notify me of a change in database.
    My code:
    Dim gOraSession As Object
    Dim gOraSubscriptions As OracleInProcServer.OraSubscriptions
    Dim gOraDatabase As OracleInProcServer.OraDatabase
    gOraSession = CreateObject("OracleInProcServer.XOraSession")
    gOraDatabase = gOraSession.DbOpenDatabase("<database_instance>", "<username>/<password>", OracleInProcServer.dbOption.ORADB_ENLIST_FOR_CALLBACK)
    gOraSubscriptions = gOraDatabase.Subscriptions
    gOraSubscriptions.Add("<queue_name>:<subscriber>", DBEventsHdlr, A) --------ERROR
    gOraSubscriptions(0).Register()
    I get the Type Mismatch error on the line before the last one. What could be the problem?

    Hi I am connecting to Oracle 9 database using OracleInProcServer library from my .NET 1.1 project.
    I want to use database events so Oracle can notify me of a change in database.
    My code:
    Dim gOraSession As Object
    Dim gOraSubscriptions As OracleInProcServer.OraSubscriptions
    Dim gOraDatabase As OracleInProcServer.OraDatabase
    gOraSession = CreateObject("OracleInProcServer.XOraSession")
    gOraDatabase = gOraSession.DbOpenDatabase("<database_instance>", "<username>/<password>", OracleInProcServer.dbOption.ORADB_ENLIST_FOR_CALLBACK)
    gOraSubscriptions = gOraDatabase.Subscriptions
    gOraSubscriptions.Add("<queue_name>:<subscriber>", DBEventsHdlr, A) --------ERROR
    gOraSubscriptions(0).Register()
    I get the Type Mismatch error on the line before the last one. What could be the problem?

  • Database event in caps

    Hi everyone
    I need to know if there's a way to manage database events (such as a row insert) in CAPS. Can I implemlent (or import) a trigger made in SQLServer2000 with SQLServer eway?
    Thanks
    Ivano

    Hi Sohit,
    It must work. you keep a break point and check. I had used the same  same thing in one of my object.
    the logic would be to
    LOOP AT TOTAL.
    Now check the record of TOTAL which you want to check by using offset like  TOTAL+0(4) i.e. the first four characters of the total which is for the first field and by taking it do the validation by checking teh database or whatever if fails raise the error message.
    ENDLOOP.
    If you have any doubt write back i'll help you.
    <b>Kindly reward points if it helps.</b>
    Thanks and Regards
    Tanweer zaki

  • Database Event Subscription with oo4o c++

    Hi,
    how do I subscribe to Database events using oo4o for C++ API? oo4o does provides OraSubscription object but I can't seem to find its equivalent class in C++.
    Your help will be greatly appreciated.

    Hi,
    how do I subscribe to Database events using oo4o for C++ API? oo4o does provides OraSubscription object but I can't seem to find its equivalent class in C++.
    Your help will be greatly appreciated.

  • Error saving job to database

    Hi,
    In IDES ECC6.0 Ehp 3 (Os: window 2003 64bit    DB: oracle 10.2.0.2) server when iam goto T-Code -- SM36 -- Standard Jobs -- Default Scheduling iam getting below error.
    <error saving job to database>
    So I patched oracle 10.2.0.1 to 10.2.0.4, and kernel patch with latest one.
    But, the same error occured.
    I tried to execute r3trans -d at the OS level,the results is <The system cannot execute the specified program>.
    In SM21, i am getting below error
    <error saving job to database>
    &CAUSE &
    The SAP system was unable to save the current job in the database. This failure suggests that there is a problem with the database system or with the network connections between the SAP application servers and the database system.
    &SYSTEM_RESPONSE&
    Job not saved and not scheduled.
    &What_TO_DO&
    To analyze this problem, start by checking the <DS:TRAN.SM21>system log for message about network or database problems. you can also use the <DS:TRAN.SRZL>computing center management system to check your system for problems. >
    I checked SM28 and SICK and it reports no error.
    Please help how can I schedule the standard jobs

    Make sure you use the proper kernel, for 64bit there are two kernels:
    - one for AMD64 and Intel64
    - one for Itanium-2 64bit
    The R3trans seems to be the wrong one - as I would suggest are the brtools.
    Markus

  • How to schedule a background job using the Event concept..?

    Hi Folks,
    I have a requirement that, I need a schedule a background job.
    Once after the previous job successful only, new job should get triggered. How to go ahead with this..?
    For Eg, I am scheduling a job called ZTEST periodically for 1 minute. If the job is not get completing with in 1 minute, I dont want to start my new job. Only after the success of my old job, I want my new job to run.
    Waiting for ur replies.
    Regards,
    Savi.

    Hi,
    You can use events that have already been defined, or you can create new events for scheduling background jobs.
    If you wish to use new events, do the following to implement the event scheduling:
    Define and transport the event as a user event with transaction SM62.
    You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.
    If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.
    Do this to transport an event:
    Create a transport request.
    Start the editor in the transport request and enter the following:
    R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.
    Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event ID’s that you have created.
    Save and release the transport request. Ensure that it is imported into your production system(s).
    To trigger an event, add:
    – the function module BP_EVENT_RAISE to your ABAP program, or
    – the program SAPEVT to your external script, batch file, or program.
    When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.
    Schedule the jobs that are to run when your events are triggered.
    You can schedule jobs for one-time start or to be started whenever an event is triggered.
    Regards,
    Raj.

  • Please help me to run a submitted job in database

    Hi, Guys:
    I need your help for a problem:
    I need to have a job runnning every day midnight to update a column in a table, so I wrote a procedure to do it, submit job as follows:
    set serveroutput on;
    declare
      n_jobno BINARY_INTEGER;
    begin
      dbms_job.submit(job=>n_jobno,  what=>'begin SOR_CHECKSUM_SERVICE.porpulate_Checksum; end;',next_date=>trunc(sysdate)+15/24+6/288,interval=>'trunc(sysdate+1/288,''MI'')');
      commit;
      dbms_output.put_line('Job Number:'||n_jobno);
    end;But the job is never running. I checked dba_jobs
    select job, last_date,last_sec, log_user, next_date, next_sec,schema_user, total_time, what,instance from dba_jobs;it shows the following result:
    4001     27-AUG-12     11:36:51     SYS     27-AUG-12     19:36:51     APEX_030200     10.00000000000000000000000000000000000002     wwv_flow_cache.purge_sessions(p_purge_sess_older_then_hrs => 24);
    4002     27-AUG-12     15:31:42     SYS     27-AUG-12     15:41:42     APEX_030200     468.999999999999999999999999999999999997     wwv_flow_mail.push_queue(wwv_flow_platform.get_preference('SMTP_HOST_ADDRESS'),wwv_flow_platform.get_preference('SMTP_HOST_PORT'));
    69               SORS     27-AUG-12     15:30:00     SORS     313     begin SOR_CHECKSUM_SERVICE.porpulate_Checksum; end;the the dba_jobs shows with instance number as 0,
    however, when I run the
    select *
    from v$instance;1     apexsb     lsgapps.thruhere.net     11.2.0.1.0     01-AUG-12     OPEN     NO     1
    instance number shows 1.
    Is thsi because I submit my job to a wrong database instance? or any other reason?
    Thanks a lot for your time.
    Sam

    the the dba_jobs shows with instance number as 0,Where? Not in your example....
    (How do you do that, by the way? Posting unformatted code with {noformat}{noformat} tags?)
    Check alert.log and trace files in your udump directory for additional clues.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for