After update row level trigger help

Hello,
I have to update some data on a table. I need to be able to undo the update just in case something goes wrong after update is comitted. I decided to keep track of updated rows by inserting new and old values on a audit table using UPDATE ROW LEVEL trigger. Everything working fine as I wished, but here is what I am having a problem in separating each bulk of update by a unique ID... I am not talking about any primary key or autogenerated sequence key here.
Audit table inserts values: primary key of table, old value before update, new value after update, and time stamp. Now, I want add one more field on the audit table that indentifies each bulk of UPDATE operation... I tried to use session ID, it works fine, but sometimes I may update two or three times, maybe around same time, on the same day from the same session (timestamp doesn't help me). In that case, each UPDATE operation inserts the same session ID on Audit table. I won't know which update operation populated which row of the audit table.
Can somebody give me how I can resolve this situation. Again, this has to be inside the trigger. Is there any other IDs that I can use? I would appreciate your help. Thanks,

Can you add a table level trigger in addition to your row level trigger? If so, you could do what you want in there. In the new trigger, formulate a unique value (such as session id || sysdate) and store it using dbms_application_info.set_module and set the MODULE to that value. Then, in your row level trigger code, execute dbms_application_info.read_module and pull the MODULE value and insert it into your audit table.
The use of session id || sysdate should be fine (and unique) in this context. You'd just have to know at what time the UPDATE batch occurred that you wanted to undo.
By the way, you could use LogMiner to do what I think you're trying to create with the use of your trigger code and table entries. Recall the Oracle keeps the undo and redo data for every row that is updated in the redo/archive logs. Using LogMiner, you could find and undo any change from any time. Just like your method, you'd have to know when the "bad" thing occurred in order to find the correct log and "mine" it, but all the functionality is there. There's a kinda old, but very good, article by Arup Nanda at http://www.oracle.com/technology/oramag/oracle/05-jul/o45dba.html that reviews how it all works. You may want to look at it to see if you can avoid re-inventing the wheel to meet your needs. Just a thought....
Karen

Similar Messages

  • Capturing value in after insert or update row level trigger

    Hi Experts,
    I'm working on EBS 11.5.10 and database 11g. I have trigger-A on wip_discrete_jobs table and trigger-B on wip_requirement_operations table.When ever i create discrete job, it inserts record in both wip_discrete_jobs and wip_requirement_operations.
    Note:2 tables are like master-child relation.
    Trigger-A: After Insert.Row Level trigger on wip_discrete_jobs
    Trigger-B:After Insert,Row Level trigger on wip_requirement_operations
    In Trigger A:
    I'm capturing wip_entity_id and holding in global variable.
    package.variable:=:new.wip_entity_id
    In Trigger B:
    I'm using the above global variable.
    Issue: Let's say i have create discrete job,it's wip_entity_id is 27, but the global variable is holding the previous wip_entity_id(26),not current value.It looks like before trigger A event is complete, trigger B is also in process, i think this could be the reason it's not storing the current wip_entity_id in the global variable.
    I need your help how to have the current value in the global variable so that i can use that in the trigger B.
    Awaiting response at the earliest.
    Thanks

    798616 wrote:
    Hi Experts,
    I'm working on EBS 11.5.10 and database 11g. I have trigger-A on wip_discrete_jobs table and trigger-B on wip_requirement_operations table.When ever i create discrete job, it inserts record in both wip_discrete_jobs and wip_requirement_operations.
    Note:2 tables are like master-child relation.
    Trigger-A: After Insert.Row Level trigger on wip_discrete_jobs
    Trigger-B:After Insert,Row Level trigger on wip_requirement_operations
    In Trigger A:
    I'm capturing wip_entity_id and holding in global variable.
    package.variable:=:new.wip_entity_id
    In Trigger B:
    I'm using the above global variable.
    Issue: Let's say i have create discrete job,it's wip_entity_id is 27, but the global variable is holding the previous wip_entity_id(26),not current value.It looks like before trigger A event is complete, trigger B is also in process, i think this could be the reason it's not storing the current wip_entity_id in the global variable.
    I need your help how to have the current value in the global variable so that i can use that in the trigger B.
    Awaiting response at the earliest.
    ThanksMy head hurts just thinking about how this is being implemented.
    What's stopping you from creating a nice and simple procedure to perform all this magic?
    Continue with the global/trigger magic at your own peril, as you can hopefully already see ... nothing good will come from it.
    Cheers,

  • Row level trigger updating the entire table instead of affected rows

    I am using orace 8.1.7. My problem is I have a row level trigger that should fire only once ( and insert a row in my auditing table). But it is doing it for the entire table. This only happens when I have more than two columns in an Update clause. Has anyone run into this problem before. Any help would be highly appreciated.
    thanks,
    dinesh

    create or replace trigger contact_audit
    before update or delete on contact
    for each row
    declare
    v_audit_type char(1);
    v_audit_item varchar2(64) := 'CONTACT';
    v_acct_seqid number;
    Begin
    if inserting then
         v_audit_type := 'I';
    elsif updating then
    v_audit_type := 'U';
    elsif deleting then
    v_audit_type := 'D';
    end if;
    select acct_seqid into v_acct_seqid
    from account_contact
    where email = :old.contact_email;
    insert into audit_event ( id, audit_item, audit_type, audit_date, acct_seqid, col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8,
    col_9, col_10, col_11, col_12, col_13, col_14, col_15, col_16, col_17, col_18, col_19, col_20)
    values (audit_event_sq.nextval, v_audit_item, v_audit_type, sysdate, v_acct_seqid, :old.contact_email, :old.contact_type, :old.contact_last, :old.contact_first,
    :old.title, :old.address1, :old.address2, :old.address3, :old.city, :old.state, :old.zip_code5, :old.zip_code4, :old.zip_code_barcode, :old.country, :old.phone_no,
    :old.phone_ext, :old.receive_info_email_yn, :old.pwd_encrypted, :old.pwd_question, :old.pwd_answer);
    End;

  • Getting iteration number in row level trigger

    Hi. Is there a way to get iteration number in row level trigger? Or to access data inserted in statement level trigger from row level trigger (statement level trigger are supposed to be executed before row level triggers but I cannot access them).
    I'm using Oracle 10g.

    My oracle version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    And business problem is like this:
    I need to have two log tables for some tables in my database:
    First log table is a statement level log. After insert or update or delete it should get one new row with mentioning date, time, sid, query type and some additional information.
    Second table should include all columns from table logged, date, time, sid and operation type.
    The problem is, I need exact the same date and time for each row in both log tables.
    Someone said that sysdate should return same value for query execution time. But it have nothing to do with triggers fired on this query.
    So you may say that I'm curious about getting exact same date and time for one statement level trigger and for each execution of row level trigger.

  • HT4623 i have dought if my iphone 4 will not work properly, as i heard it become slow after update ios7 , can someone help me out what to do.. ?

    i have dought if my iphone 4 will not work properly, as i heard it become slow after update ios7 , can someone help me out what to do.. ?

    Hello there, morganbailey02.
    The following Knowledge Base article provides some great steps for troubleshooting your issue:
    iOS: Unable to update or restore
    http://support.apple.com/kb/HT1808
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro

  • No System Startup after Update 10.4.10 - Help?

    Hi,
    after updating to 10.4.10 Mac OS X was not completely startup. It was hanging at the end of the blue loading bar every time.
    I was running the Hardware Test on the OS X Installation DVD and the harddrive testprogramm. Everything was ok. I could start the system in the "Safe Mode". I read that a new system installation could fix startup problems. So I reinstalled OS X. Everything was running OK. Then I updated to 10.4.10 again and I have the same Problem again!
    I read about a quicktime component problem, so I reinstalled Quicktime in the "Safe Mode" like they were writing, but nothing helps.
    After the Update to 10.4.9 my system seemed to be slower, but now it does not even startup. It always hangs at the end of the blue loading bar.
    My System:
    MacMini - 1,83 GHz (Intel)
    1 GB-RAM
    SuperDrive
    AirPort
    80 GB Harddrive
    Any ideas??
    Thanks for help.
    Matthias
    MacMini, 1,83 GHz, 1GB Ram Mac OS X (10.4.10)
    Mac OS X (10.4.10)

    Matthias
    Welcome to Apple Discussions!!
    I could start the system in the "Safe Mode".
    Well try a normal startup, that fails, then start up in Safe Mode and immediately use the Console application (in /Applications/Utilities) to look at your system.log. Go back to where it says "reboot by <user>" and look at the lines immediately before that. Post some of them here.
    If it starts OK in safe mode, but not otherwise, then there may be a problem with one or more of the items listed in Mac OS X: What is Safe Boot, Safe Mode?.
    Since you don't get as far as being able to log in, it is unlikely that Login Items are a problem. Equally it is not likely to be the font caches mentioned since they are user specific. I would be inclined to start with the fonts in /Library/Fonts, and then work backwards in the list.
    See these User Tips for more about fonts:
    Font Management in OS X Panther (Kurt Lang)
    Fonts and Apple Type Services, part 1 (J.Otava)
    Fonts and Apple Type Services, part 2 (J.Otava)
    Fonts and Apple Type Services, part 3 (J.Otava)
    (sorry my links don't work any more, but you can search the User Tips forum for these)
    Let us know how you get on, and if you need more help!

  • Can't connect to internet after updating new Firmware wrt54g Help please!

    So i just updated my firmware on my wrt54g ver 2 router, went through all the steps it updated successfully after that i hit the reset button and unplugged the router as tehe online instructions said to. Now i can't connect to the interent at all with either of my two wired computers or through the wireless. All the lights on the front of the router are on like the power, internet, and wireless connectivity. Also the the two WAN ports my computers are connected to in the router the lights are on and it's recognising them. But I can't connect to the internet or even see the router on my network settings. Somone suggested to reconfigure the router but when i go to set up new connection my computer doesn't detect the router and also i cant connect to the router using the ip address 192.168.1.1/ since there is no internet connection. Is there a way to get to the router options or a way to revert it to its old firmware. Any help would be much appreciated. I should after updating the firmare the power button is contantly blinking.

    I am having the exact same problem..  I have the same router and same version as well.. I followed the directions and upgraded the firmware. it said update successfull and then I reset it and power cycled it to find that my network no longer works and I cannot access the router..I've looked through all the troubleshooting guides and they do not help..  It says if you can't access the web based page then to use the TFTP  utility to re-flash the router’s firmware but it seems it cannot make a connection to the router..  I've tried to ping it like it says to in the TFTP guide but it does not seem to be able to make a connection to the router..  I tried to access Management Mode to recover the router and resume the loading of the firmware upgrade but I can't get the Management Mode Firmware Upgrade page to open as well..  So what gives?  I followed the directions  but the only thing I seemed to accomplish was to brick my router..   Does anyone have a clue on how to go about fixing this problem?   Any help is appreciated.. 

  • Issues with game center after updating Ipod! Please help

    After updating my daughters Ipod touch it wouldn't let us login to her game center account. Is there a way to look up her apple id for game center just by her game center name and nickname? When we login with her email address she had to create a new nickname and everything however we have previous emails from friend requests. Can anyone help us? I don't know what else to do she doesn't want to loose all the games that she has been playing for months. It's weird how it says her email is a new apple id when that is what she used before to create her game center account. All help appreciated. Thanks.

    Try holding down the sleep/wake and home button until iPhone shuts off. Then hold down the home button while plugging into your computer. Your iphone is now in recovery mode. iTunes will detect this, and you can attempt to restore/update from there.
    Best of luck.

  • Wifi iPad 3 charger stopped working after updating to iOS 6, help!

    Wifi iPad 3 charger stopped working after updating to iOS 6.  The little iPhone charger charges it very very slowly, but the charger gets really hot after a while.  I restored it and everything works but the charger.  It's only a few months old, should I try a new iPad wall charger block?

    Hi,
    I did this after reading the forums and it made no difference. it has actually charged from 14% to 67% but thats taken over 12 hours.
    Will monitor it and if no joy will go to a apple store
    Thanks

  • TS4429 NO SIGNAL AFTER UPDATING LATEST SOFTWARE ANY HELP PLZ

    got no signal after downloading latest software anyone help please

    Hi norrod
    If you hadn't already been to the phone shop I would have said it is most probably a hardware fault in the antenna circuitry of the phone.
    Can you remember the phone being dropped at any time?
    Happy to have helped forum in a small way with a Support Ratio = 37.0

  • Execution of Row level trigger in Oracle Streams.

    Hi All,
    Oracle Database version : 9.2.0.4 on windows NT/2000 environment.
    We managed to install,configure oracle stream technologies.
    Oracle Stream seems to be working fine for replication of DML & DDL changes from source database to target database.
    Following is detail at source end.
    Source Sid = acc
    Source Schema = stream
    Source Table = dept
    structure of dept table.
    Name Null? Type
    DEPTNO NOT NULL NUMBER(5)
    DNAME NOT NULL VARCHAR2(10)
    LOC NOT NULL VARCHAR2(10)
    Streamadmin user = strmadmin
    Following is detail at target end.
    Target Sid = fin
    Target Schema = stream
    Target Table = dept
    structure of dept table.
    Name Null? Type
    DEPTNO NOT NULL NUMBER(5)
    DNAME NOT NULL VARCHAR2(10)
    LOC NOT NULL VARCHAR2(10)
    TRAN_DATE                    NULL DATE DEFAULT SYSDATE
    I checked on insert/update/delete of rows into dept table at source database, changes are correctly replicated to target table dept.
    I wrote a simple trigger which is as follows on dept table at target database.
    create or replace trigger dept_upd_del
    before delete or update of dname,loc on stream.dept
    for each row
    begin
    dbms_output.put_line('Inside Trigger');
    if updating then
    dbms_output.put_line('Update');     
    insert into stream.dept_change values (:old.deptno,'U',sysdate);
    end if;
    if deleting then
    dbms_output.put_line('Delete');
    insert into stream.dept_change values (:old.deptno,'D',sysdate);
    end if;
    end;
    I expect this trigger to get executed whenever changes occurs into dept table at target database whenever dml changes are propagated from source to target table. However i found that the above trigger is not executed at all.
    I was further surprised, since incase i update/delete rows from target table dept the above trigger is executing correctly.
    Can someone please let me know about this?
    I believe stream technology is using INSERT / UPDATE & DELETE statement when changes are applied at target table but this doesn't seems to be the case.
    Thanks in Advance.
    Regards,
    Vidyanand

    The trigger at the destination will not fire because it already has at the source site. Read about that in the streams documentation on page 4-25. To change the "fire once" property of the trigger, use the procedure SET_TRIGGER_FIRING_PROPERTY in the DBMS_DDL package.
    Hope this helps.
    Claudine

  • Unable to Load Mac OSX after update - Urgent! Please Help

    I just updated my Mac using System update, which required a start.
    I restarted the computer, but it's stuck in the gray apple screen with the circular running bars. It's been now 10 minutes, and it never took so much. I tried to turn it off, then on again, same problem. What should I do? Please, help!
    Thanks,
    richard

    Problem solved.
    First of all, thank you all for the advices and links, now I learned something. After panicking, I tried the PRAM reset restart and the "shift" restart and it didn't work. I didn't have the installation disk with me, so I went straight to Tekserve to hear them. They told me that my system got corrupted for some reason and I had two options with them:
    - a quick fix, for US$59, which would erase all my HD content and take 24 hours
    - a fix without erasing the HD, for US$195, which would take 4 business days!
    They said those were all the options. For me the money was not major problem. The big issue for me would be not having my computer for many days.
    Then I thought: what if I try to reinstall the system myself? And they said: well, you can try that.
    That's what I did as I got home. Install disk, restart holding down the "C" key.
    One hour later, everything was back to normal.
    Now the question: why at tekserve they didn't say anything to me about reinstalling the system myself?
    Anyway, this was the first major problem I bumped into since I have turned to apple 3 years ago.
    And again, thanks everybody for the help!

  • Push Notifications not working on any app (Whatsapp, Beejive, Mail) after update 5.1.1, Help!

    I'm gonna try to be clear with my problem. I have a Gmail Account working on Microsoft Exchange, for IM messaging I'm using Beejive IM with Push and I'm also using Whatsapp.  Before Updating it to iOS 5.1.1 all Push notifications were working flawless, however, after I upgraded it to 5.1.1, I began having troubles. After 1 minute of having the Iphone locked, I don't get any push notification, nor on the email, nor on the Whatsapp, neither on the Beejive. If I unlock it and I re-open one of them, for ex, I go to check my contact list on Beejive, I get all the mails, and all the instant msgs that people had sent to me after I locked my iPhone; it's like, my iPhone was locked for 30 minutes. In those 30 minutes people sent me 4 msgs on whatsapp, 4 msgs on beejive and 4 mails. Once I unlock my iPhone and I go to one of the 3 apps (mail, whatsapp or beejive), I get the 12 items (4 msg from whatsapp, 4 msgs from beejive and 4 mails) at that exactly time. It's crazy, it's like, with this new update push notifications got disabled for every app or what happened to my iPhone on this upgrade? I really need help. WIthout Push, none of them apps works cool for me. I'm using Iphone 4 on a 3G network.
    Ps: I tried restoring it x3, I unistalled the apps, mail, etc and nothing worked.
    PS2: If someone is using whatsapp or beejive im with push on the new iOS 5.1.1 and push notifications are working good for them, please let me know it so I will know it's my iPhone hardware problem to bring it to technical service
    Thanks in advance

    SAME PROBLEM
    The Apple store are trying to say they know nothing of this problem,  they know that if  you delete your yahoo mail and then add the account again then push notification works for a day.  So they do that for you, but won't listen when you tell them that it won't be working by the next day! This is to get you out of the shop.  They don't have an answer to why your other notifications aren't working (like alerts etc) even though you have push on.
    So what are we to do?  The main point for me getting an iPhone was being able to be alerted when I received an email as I am out and about all day!
    How can we get somebody in Apple to admit this problem and find a resolve for it before we all have to go buy a phone that will notify you of your email, messages ans alert?

  • Problems with row level trigger.

    Hi there. I'm trying to create a trigger for a table ... it's an attempt to audit all changes made to the table data. I'm getting an error message however, for my new and old interviewdate. The specific message is:
    Error(12,92): PLS-00049: bad bind variable 'NEW.INTERVIEWDATE'
    Error(12,72): PLS-00049: bad bind variable 'OLD.INTERVIEWDATE'
    here's the code:
    CREATE OR REPLACE TRIGGER AUDITCHANGES
    BEFORE INSERT OR DELETE OR UPDATE
    ON WTB
    FOR EACH ROW
    DECLARE
    BEGIN
    IF :new.InterviewDate != :old.InterviewDate THEN
    INSERT INTO WITAudit (DTCHG,FLDNAME, userid, oldval, newval)
    VALUES (SYSDATE, “InterviewDate”, SYS_CONTEXT('USERENV','OS_USER'),:old.InterviewDate, :new.InterviewDate);
    END IF;
    END;
    Can you point me in the right direction?
    Thanks.

    Remove the DOUBLE quotes from this “InterviewDate”. ..
    try posting your code in between tags
    &#123;code}
    select....
    &#123;code}
    SS                                                                                                                                                                                                                                                                                                                   

  • My iphone 3Gs has gone into recovery mode after updating via itunes..help..

    I plugged my iphone 3gs into itunes yesterday and it started to update the software - presumabley to 10.5? - came back to it an hour later and it was displaying an image of a usb cable and itunes symbol which i now undertand means its gone into recovery mode.
    I tried to restore it to the factory settings as advised but it won't work. Its telling me "This device could not be restored, it is not eligible for the requested build"
    Please help - this phone is not jailbroken!

    Ok, after 2 nights searching forums and trying different things I have managed to find a solution. I had to add a '# ' at the begining of the host directory.  This means nothing to me and I had to follow the steps in the following link but it worked perfectly -
    https://discussions.apple.com/thread/3042366?start=0&tstart=0
    Hope this post helps someone else sometime.
    Matt

Maybe you are looking for

  • How can I OCR only part of a long document?

    OCR with a pdf file is usually very simple.  Not here.  This is a legal-type document (PDF) with with line numbers on the left and vertical lines on both sides of the text I want to OCR.  If OCR includes the line numbers I will have to spend hours re

  • Tolerance key PP - Lower limit

    We have configured tolerance key PP with lower limit of 0$ for both absolute and percentage. When I try to post the invoice with a lower price, I receive a warning message that the price is too low (which is correct). The problem is that when I try t

  • Delete standby database fails

    Hello, I setup replication on database A in server A to Server B and on the same database A i have logshipping setup as well to Server C. Now I removed logshipping configuration on database A in server A and trying to delete the mirrored copy of data

  • Lately, whenever I open a link in a new window, when that window opens it immediately minimizes down to the task bar. This is obviously annoying.

    Lately, whenever I "open a link in a new window", when that window opens it immediately minimizes down to the task bar. This is obviously annoying.

  • Cs6 problems with gtx 780 cuda

    hey i have problems with cuda with my gtx 780 when i try to see my cuda version in after effects i cant see the cuda setting and in premier pro i cant enable cuda acceleration i have added pictures