Trigger based approach to capture changes in OLTP DB

I have this scenario where we need to capture changes (updates/deletes) to transaction tables in our OLTP database. The changes will be populated to temp tables and then moved to Hadoop for analysis. The OLTP table record huge volume of data on a daily basis, some tables having thousands of updates every day and some having a few million.
We have thought of using a trigger-based approach, where a trigger in the OLTP tables will take care of inserting records in the temp tables. It will be a "After Update and Delete" trigger as:
IF updating THEN
      BEGIN
       insert into temp table // insert statement here
      EXCEPTION
         WHEN others THEN
           null;
      END;
  ELSIF DELETING THEN
     BEGIN
       insert into temp table //insert statement here
      EXCEPTION
         WHEN others THEN
           null;
      END;
   END IF;
END;Please let me know if this is an acceptable approach. Are there any better ways of doing the same?
I am using Oracle 11g r1.

>
So, as a test, I created a table called test, with a PK on col1.
Then, I created a MV on it,
Next, I inserted 2 records, committed, and deleted 1 record, and did commit.
The RUPD$_TEST is empty, but the MLOG$_TEST has data.
>
The RUPD$_TEST is a temporary table that Oracle creates and uses with primary key based MV logs. As a temporary table you won't see data in it unless your session puts data there.
>
But how do I read this data?
>
What data? You didn't log any data to read.
Here is an example that doesn't even use a primary key - just a plain old table with familiar data.
create table emp_copy as select * from emp
create materialized view log on emp_copy
with rowid, sequence (empno, ename, job, mgr, hiredate, sal, comm, deptno)
including new values;
insert into emp_copy (empno, ename) values (9999, 'test')
delete from  emp_copy where empno = 7369
update emp_copy set job = 'NEW JOB' where empno = 7499
select * from mlog$_emp_copy
EMPNO     ENAME     JOB     MGR     HIREDATE     SAL     COMM     DEPTNO     M_ROW$$     SEQUENCE$$     SNAPTIME$$     DMLTYPE$$     OLD_NEW$$     CHANGE_VECTOR$$     XID$$
9999     test                                   AAAUayAAEAAAAJVAAO     1     1/1/4000     I     N     FEFF     844454994905658
7369     SMITH     CLERK     7902     12/17/1980     30          20     AAAUayAAEAAAAJVAAA     2     1/1/4000     D     O     0000     844454994905658
7499     ALLEN     SALESMAN     7698     2/20/1981     1600     300     30     AAAUayAAEAAAAJVAAB     3     1/1/4000     U     U     0800     844454994905658
7499     ALLEN     NEW JOB     7698     2/20/1981     1600     300     30     AAAUayAAEAAAAJVAAB     4     1/1/4000     U     N     0800     844454994905658SNAPTIME$$ shows the SEQUENCE of events.
XID$$ shows the transaction id
DMLTYPE$$ I/D/U for Insert/Update/Delete
For the Insert you can see the new EMPNO and ENAME
For the Delete you can see the values that were in the deleted row
For the Update you can see the old job 'SALESMAN' in sequence #3 and the new job 'NEW JOB' in sequence #4
Just pull the data that you haven't mined/processed yet based on SNAPTIME$$ and then delete those rows when you are done with them.
It took a few minutes to create that example and start collecting change data. Oracle will collect the changes automatically. All the user needs to do is manage the MV Log to keep it from growing indefinitely.
For some uses you may not need the actual column values; maybe you just want to know what ROWS in the table changed. This modified example uses ROWID but you could use primary key instead.
create materialized view log on emp_copy
with rowid, sequence;
insert into emp_copy (empno, ename) values (9999, 'test')
delete from  emp_copy where empno = 7369
update emp_copy set job = 'NEW JOB' where empno = 7499
select * from mlog$_emp_copy
M_ROW$$     SEQUENCE$$     SNAPTIME$$     DMLTYPE$$     OLD_NEW$$     CHANGE_VECTOR$$     XID$$
AAAUa3AAEAAAR+mAAA     5     1/1/4000     I     N     FEFF     1.68898729922029E15
AAAUa3AAEAAAR+jAAA     6     1/1/4000     D     O     0000     1.68898729922029E15
AAAUa3AAEAAAR+jAAB     7     1/1/4000     U     U     0800     1.68898729922029E15There are the ROWIDs for the rows that have changed. The row for the delete MAY not be in the table anymore. The original row with that ROWID was deleted (SNAPTIME$$ = 6) but there could be a later INSERT whose row now has that ROWID. And if ROW MOVEMENT is enabled the rowid of a row could change.
For that last example you would access the MASTER table (emp_copy) and pull rows based on ROWID. Those are the rows that have 'changed' since the last time you mined the MV log.
I don't know how it can get any simpler than that! ;)

Similar Messages

  • Change Capture For Siebel OLTP task in DAC running for more than 10 hours

    whole etl load used to complete in 2 hours (as on now siebel data having sample data). since last Friday Change Capture For Siebel OLTP task in DAC execution plan running for more than 10 hours. I am not able to trouble shoot the problem because no log for this task
    what could be the reason for this problem? how can I fix that problem?
    Appreciate your help
    Thanks
    Jay.

    Which ETL is it that is taking the longest (is it an SDE, SIL, PLP?). I have seen someOracle vanilla ETLs coded in a way that is very ineffective. Check the DAC and Informatica logs and find out which mapping it is and where the delay is (e.g. SQL, write to DB..etc).

  • Is sql server using trigger to capture change data in SQL server CDC?

    hi all,
    what is the Architecture of SQL server change data capture(CDC)? is sql server using trigger to capture change data in SQL server CDC? for example Change Data Capture (CDC) in SQL Server 2008 using we can capture change Data records INSERTs, UPDATEs, and
    DELETEs applied to SQL Server tables.so my question is SQL server using triggers to capture change data like INSERT TRIGGER, UPDATE TRIGGER and DELETED TRIGGER using each tables after enabled CDC...?
    Thanks
    Tharindu Dhaneenja 
    Tharindu Dhaneenja http://dhaneenja.blogspot.com

    It is not using triggers. The source is the transaction log.
    Related link:
    Basics of Change Data Capture
    ...The source of change data for change data capture is the SQL Server transaction log. As inserts, updates, and deletes are applied to tracked source tables, entries that describe those
    changes are added to the log. The log serves as input to the change data capture capture process. This reads the log and adds information about changes to the tracked table’s associated change table. Functions are provided to enumerate
    the changes that appear in the change tables over a specified range, returning the information in the form of a filtered result set. The filtered result set is typically used by an application process to update a representation of the source in some external
    environment. ...
    Kalman Toth, SQL Server & Business Intelligence Training; SQL Server 2008 Training

  • Capture change on certain columns only in ODI,

    Hi experts:
    Need you help to suggest the proper way to meet the following requirements.
    Requirements”
    (a) Source– Oracle 11g, need to track changes to 2 columns only - [Table A, Column A1] & [Table B, Column B1]. These 2 columns may be changed many times during a day.
    (b) Every 4 hours, based on what are captured from (a), find out the distinct rows changed (i.e. based on primary keys of Table A, Table B) , and only ship the most current row images for these rows to target
    (c) Target – Sybase, meet to perform transformations on the 2 column values (i.e. Column A1, Column B1) to map to target table [Table C, Column C1]
    From my limited understanding, I think trigger-based CDC is to be used. However, not sure how to do this , especially (a) and (b). For example, where do we configure trigger logic to achieve (a) from the ODI studio ?
    Your help is much appreciated.
    Regards

    Hi,
    887999 wrote:
    Hi experts:
    Need you help to suggest the proper way to meet the following requirements.
    Requirements”
    (a) Source– Oracle 11g, need to track changes to 2 columns only - [Table A, Column A1] & [Table B, Column B1]. These 2 columns may be changed many times during a day.
    (b) Every 4 hours, based on what are captured from (a), find out the distinct rows changed (i.e. based on primary keys of Table A, Table B) , and only ship the most current row images for these rows to target-- Check out the JV$ and JVD$ views that are created when you start the ODI Journal, they do exactly what you have described in (b) - You get the latest update based on the SCN number when they occured.
    (c) Target – Sybase, meet to perform transformations on the 2 column values (i.e. Column A1, Column B1) to map to target table [Table C, Column C1]To be honest the target is irrelvant, you just need to decide if you want to do the transformation on the source on the way out of oracle (set staging area different to target and choose your Source logical schema).
    I would design an interface that uses Table A and Table B as the sources, do the join , transformation on Oracle and map to Target Table C, choose your staging area based on where you want the joins / transformation to take place, pick a Knowlege module based on Technology and how you want to update the target.
    >
    From my limited understanding, I think trigger-based CDC is to be used. However, not sure how to do this , especially (a) and (b). For example, where do we configure trigger logic to achieve (a) from the ODI studio ?You can use Synchronous (Trigger based) or Asynchronous (Logminer / Streams based) to perform what you want, see this nice guide on setting up CDC and consuming the changes :
    http://soainfrastructure.blogspot.ie/2009/02/setting-up-oracle-data-integrator-odi.html
    If your friendly with your source system DBA then I prefer Asynchronous CDC , its less intrusive than triggers, it does however need a bit of knowledge on how to monitor it, Metalink / Support has plenty of info.
    >
    Your help is much appreciated.You welcome, have a play with it in a demo environment and get a feel for how you consume the captured changes (Lock Subscriber, Extend Window, Consume, Purge + Unlock, Loop) etc.
    The guide I've linked to uses an ODI WAit for Data to trigger the consumption of changes, you have stated every 4 hours so I would skip the ODI wait for data and simply schedule your package to run every 4 hours.

  • Oracle Trigger - How can I capture and correct on the fly  ORA-01847

    Oracle Trigger - How can I capture and correct on the fly ORA-01847 day of month must be between 1.
    I have a table that has a date column. Sometimes an invalid date is passed and I'd like to capture and initilize the incoming value to null and have it inserted without error. Currently I get ORA-01847 day of month must be between 1.
    Example:
    create table ep1
    col_1 number,
    col_2 date
    Now if a user does the following, I want no error to occure but rather for the date value to be set to null and inserted.
    insert into ep1 values('1', '41-JAN-13')
    The insert may come from any client and I can't change the calling code hence can't used a precedure to replace the insert. I'm guessing there is some way to catch system level exceptions on the DB level. This doesn't need to be nice, it just needs to work.
    Here is the question on experts exchange. I'm told there is no way, but there must be. After all the exception is on a DB system level and I would think one could extend or override these, or disable them.
    http://www.experts-exchange.com/Database/Oracle/PL_SQL/Q_23045306.html

    SQL> declare
      2     wrong_month      exception;
      3     pragma exception_init (wrong_month, -1843);
      4  begin
      5    begin
      6      insert into emp (empno, hiredate)
      7      values (2345,to_date('13/25/81','MM/DD/YY'));
      8    exception
      9      when wrong_month then
    10      dbms_output.put_line('I caught the bad month');
    11      insert into emp (empno, hiredate)
    12      values (2345,null);
    13    end;
    14  end;
    15  /
    I caught the bad month
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from emp
      2  where empno = 2345;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          2345Note the 1843 error vice 1847. It can be done outside of a trigger.

  • How to capture changed data at ALV screen

    Hi ALV Experts,
    I am using Following method for ALV display :-
      CALL METHOD g_alv_grid_0200->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer            = 'X'
          is_layout                          =
          it_toolbar_excluding          =
        CHANGING
          it_outtab                          =
          it_fieldcatalog                   =
      CALL METHOD g_alv_grid_0200->set_ready_for_input
        EXPORTING
          i_ready_for_input = '1'.
    Now I am changing few values in ALV screen and capturing through following Method :-
      CALL METHOD g_alv_grid_0200->check_changed_data
        IMPORTING
          e_valid = l_valid.
    THIS ABOVE METHOD STRANGELY CAPTURES CHANGES IN QUANTITY AND DATE FIELDS ONLY AND NOT IN CHARATER FIELDS.
    Can somebody suggest how to capture changes of character fields also.
    Thanks in Advance,
    Chandan

    Hi,
    Check whether the following logic helps.
    p_er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
    DATA :
        lwa_mod_cell TYPE lvc_s_modi,
        lwa_mod      TYPE ty_mod.
    LOOP AT p_er_data_changed->mt_good_cells INTO lwa_mod_cell.
        lwa_mod-row  = lwa_mod_cell-row_id.
        APPEND lwa_mod TO i_mod.
    ENDLOOP.
    Regards,
    Lohitha

  • Help!  Batch Capture Changes My Logged Clips' Media Start & Media End

    I'd be very grateful for any help on this.
    I log a tape with about 40 clips ranging from 30 seconds to 4 minutes. I select the clips and start a batch capture. Everything appears to be capturing normally and I receive no error messages or dropped frame warnings - after my last clip is captured I get a "Successfully Captured" message.
    However, as soon as I click "Finished," all of my clip media start's, media end's, and durations in the log window arbitrarily change to weird times. All my media start points are 26 frames too early (I've tripple-checked that "Add Handles" is indeed deactivated), and the media end points make no sense at all.
    A clip that was once 44 seconds long is now only 12 seconds long, the media end point moved a whopping 34:03 too early. Another clip will become 2 seconds longer, the media start point still shifted back 26 frames, but with the media end now 31 frames too late. Checking the original files on my drive confirms that only these weird, unusable segments are what has been captured.
    What complicates things is that I just discovered today that if I capture locally to my internal hard disk, the clips capture normally (the times remain unchanged). But if I set my capture scratch to my external hard drive (a LaCie F800 2-TB RAID-5 using Firewire-800), that's when the clips start changing themselves. I ran disk utility and found no errors on the drive, and have never had a problem with it or any part of my configuration until the last month or so... the only changes to my system being the regular use of Software Update.
    On top of that, my colleague is experiencing a similar problem with batch capture changing his clip times, even though he is using a different computer (single-processor G5), a different video deck (Sony DHR-1000), and a different storage medium (Apple Xserve RAID).
    So my question is: What is happening! The only thing I can think of is that perhaps some update has a bug - but I can't find anyone with a similar problem online.
    Any help on this would be extremely appreciated! Thank you in advance for your advice.
    Dual 2.3GHz PowerPC G5 Mac OS X (10.4.4) Deck: JVC CU-VH1 / Storage: LaCie F800 2-TB RAID-5
    Dual 2.3GHz PowerPC G5 Mac OS X (10.4.4)

    Here's an update on this. Both my colleague and I have confirmed that if we capture to an internal or external drive that is not a RAID FCPro batch captures just fine.
    But, if the drive we are capturing to is a RAID (in my case a LaCie Biggest F800 and his case an Apple Xserve), then we get dropped frame reports and/or clip in's and out's changing after the batch capture is complete.
    We even tried reformatting one of the xServe's and rebuilding it as non-journaled, it didn't solve the problem.
    It seems impossible that we're the only ones to be experiencing this problem... does anybody have any help or suggestions!?

  • How to split the IDOCS based on document number change whit out BPM

    Hi all,
    Thanks,for giving the responce..
    Scenario:File to IDoc.
    Problum1 : How to Split the IDocs based on document number change in the source file with out BPM.My file contains document numbers like
    20000092
    20000092
    20000092
    50000050
    50000050
    50000065
    I want 3 IDocs in target system.i.e 1 for 20000092,20000092,20000092
                                                       2 for 50000050,50000050
                                                       3 for 5000006
    By using external definations i am getting 6 IDOCs insted of 3.
    Problum 2:Is there any chnges/modifications in Directory when we are using external definations.
    Could u plz provide me the step by step process(Repository/Directory) with using of external definations.
    Thanks in advance.
    Regards,
    KP

    HI,
    for this no need of BPM.
    You can think of Idoc bundling concept to acheive this-just you need to do the external definition to change the idoc occurence
    /people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change
    to achieve for each document no, one idoc, you can write small user defined function in the mapping with context handling you an achieve this.
    For this e.g
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6bd6f69a-0701-0010-a88b-adbb6ee89b34
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/877c0d53-0801-0010-3bb0-e38d5ecd352c
    Regards,
    Moorthy

  • Table that captures change history of Ownership of Tranport Requests.

    Hello Folks,
                        I have been trying to locate a table that captures change in ownership of requests. I've tried Transport organizer transactions SE01 (extended view), tables E070 and E071 and SE03 but without success. Is there a table which captures change history of ownership?
    Regards,
    Prashant

    Hello Krishna,
                          This option would only work when table logging is enabled. Not otherwise. To give you a gist of my problem, one of the users from the client side created a request (authorization side is in a mess so business users also have access in Dev systems with lots of auths). He later instructed one of out functional consultants to tranfer the request from his name to the functional consultant's name. The request was later released and moved to Production system. Now the user from the client side denies that he ever created a request. (Audit issue now) and its going to snowball.
    Is there a solution.
    Regards,
    Prashant

  • Where do you capture Change Requests? I'd like to jump ahead 15 minutes or more in a FF

    With my DirecTV DV, I could jump 15 minute or greater increments with FF through a show or game.  I've read others posting about not being able to do this too.  Is there a future features list maintained anywhere?  Where do you capture changes requests and allocate them towards releases?  Is this a feature we will get anytime soon?

    You can set skip to be up to 5 minutes.
    There is also chaptering that you can use for a show that has completed recording.
    Start playback. Hit the up arrow key and you can jump ahead in the program.
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

  • Capture Changes from Sql Server  using Oracle Streams  - Destination Oracle

    Is it possible to capture changes made to tables in Sql Server database and propagate the changes to Oracle Database using Oracle Streams and Heterogeneous Gateway. I see plenty of information about pushing data from Oracle to Sql server, but I haven't been able to find much information about going the other way. Currently we are using sql server 2005 replication to accomplish this. We are looking into the possibility of replacing it with streams.

    the brief understanding i have is that there is nothing out of the tin that Oracle provides to stream between SQL Server and Oracle. The senario is documented in Oracle docs however and says you need to implement the SQL Server side to grabe changes and submit to Oracle stream queues.
    i'm sure i've seen third parties who sell software to do this.
    If you know otherwise please let me know. Also wasn;t aware one could push from SQL Server to Oracle. Is this something only avail in SQL Server 2005 or does 200 also have it? How are you doing this?
    Cheers

  • Haw to capture changes in table control?

    Hi friends,
                    please tell me the answar of this question?
                     Haw to capture changes in table control?

    Hi Rinku ,
    module TC100_tab_modify input.
    MOVE-CORRESPONDING tc100_tab TO gt_tab.
    modify GT_tab
        index TC100_TAB-current_line.
    if sy-subrc <> 0.
    append gt_tab .
    endif.
    endmodule.
    Hope this helps.
    Regards
    Caglar

  • Label Based Menu font not changing

    When using the label based menu I am changing the font size from 13 to 16, setting it as bold, changing the color and saving the model.  However, non of these changes are showing in preview mode or when exporting to pdf. How can I get this to work properly?

    Hi Suzanne,
    you need to install SP1, as this bug has been fixed there.
    You can download SP1 here:
    https://smpdl.sap-ag.de/~sapidp/012002523100007532212008E/cx2008_sp1.zip
    You can find details on how to install in the message
    Please install SP1 before posting!
    Best regards,
    Margaret

  • How to initiate a trigger based on threshold value from DAQ

    Hello,
             can anyone please tell me how to start a counter/trigger based upon a threshold value/??i would like to measure the amount of time
    the particular input value is greater than the threshold value...
    I tried out the simple VI attached, but the start time and the end time show the same values... can anyone please suggest/???
    Now on LabVIEW 10.0 on Win7
    Attachments:
    trigger.vi ‏103 KB

    sorry, attached the wrong VI,
    here you go,,, this should work....
    Now on LabVIEW 10.0 on Win7
    Attachments:
    Trigger Counter.vi ‏143 KB

  • CDHDR not capturing changes

    Hello all,
    I have written a program such that, output of program is table which captures changes for a table say J_3avasso  from cdhdr and cdpos .
    Now my problem is , new record has been created and changes has been done in same client, but i could nt able to see
    values for it in CDHDR.
    Could you please suggest solution for this
    Regards
    Bala

    Hi Bala,
    athough peoplem may condier this beeing a basic question, let me ask:
    What did your [GOOGLE SEARCH|http://www.google.cn/search?hl=de&source=hp&q=CDHDRnotcapturing+changes&btnG=Google-Suche&meta=] result tell you?
    OK, check table in dictionary, technical settings, Log data changes flag, press F1.
    The other way is if a change object has been created and the transaction creates change documents.
    Regards,
    Clemens

Maybe you are looking for