BEFORE the UPDATE of relaxation with time stamp does not work as expected

We have a scenario where I check update operations on a table.

I created a before update TRIGGER, so that every time he goes an update on the main table statement, one before the image of the lines is captured in the table of audit with timestamp.

Since it is before updating, ideally the audit table timestamp (TRG_INS_TMST) should be less main table timestamp (IBMSNAP_LOGMARKER) VALUE, I mean TRIGGER should happen before the update.

(I could understand in a way that the UPDATE statement is formulated with SYSTIMESTAMP earlier before the TRIGGER is evaluated and so UPDATE is to have a time stamp prior to TRIGGER, but this isn't what we wanted. We want PRIOR update)

'Table' IBM_SNAPOPERATION IBM_SNAPLOGMARKER            
---- ----------------- -------------------------------
T1   U                 13-OCT-15 03.07.01.775236 AM   <<---------- This is the main table, This should have the latest timestamp
T2   I                 13-OCT-15 03.07.01.775953 AM

Here is my test case.

DELETE FROM TEST_TRIGGER_1;

DELETE FROM TEST_TRIGGER_2;

SELECT 'T1', ibm_snapoperation, ibm_snaplogmarker FROM TEST_TRIGGER_1
UNION
SELECT 'T2', ibm_snapoperation, TRG_INS_TMST FROM TEST_TRIGGER_2;

INSERT INTO TEST_TRIGGER_1 (ID,ibm_snapoperation, ibm_snaplogmarker)
     VALUES (1, 'I', SYSTIMESTAMP);

COMMIT;

SELECT 'T1', ibm_snapoperation, ibm_snaplogmarker FROM TEST_TRIGGER_1
UNION
SELECT 'T2', ibm_snapoperation, TRG_INS_TMST FROM TEST_TRIGGER_2;

UPDATE TEST_TRIGGER_1
   SET IBM_SNAPOPERATION = 'U', ibm_snaplogmarker = SYSTIMESTAMP;

COMMIT;

SELECT 'T1', ibm_snapoperation, ibm_snaplogmarker FROM TEST_TRIGGER_1
UNION
SELECT 'T2', ibm_snapoperation, TRG_INS_TMST FROM TEST_TRIGGER_2;

Def trigger:

CREATE OR REPLACE TRIGGER etl_dbo.TEST_TRIGGER_1_TRG BEFORE UPDATE OF IBM_SNAPOPERATION
ON TEST_TRIGGER_1 REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
WHEN (
NEW.IBM_SNAPOPERATION= 'U'
      )
DECLARE
V_SQLCODE  VARCHAR2(3000);
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO etl_dbo.TEST_TRIGGER_2
(ID,
IBM_SNAPOPERATION,
IBM_SNAPLOGMARKER,
TRG_INS_TMST
)
VALUES (:OLD.ID,:OLD.IBM_SNAPOPERATION,:OLD.IBM_SNAPLOGMARKER,SYSTIMESTAMP)
;
--COMMIT;
END;
/

Output is something like this

1 row deleted.
1 row deleted.
no rows selected.
1 row created.
Commit complete.

'T1' IBM_SNAPOPERATION IBM_SNAPLOGMARKER            
---- ----------------- -------------------------------
T1   I                 13-OCT-15 03.07.00.927546 AM 
1 row selected.
1 row updated.
Commit complete.

'T1' IBM_SNAPOPERATION IBM_SNAPLOGMARKER            
---- ----------------- -------------------------------
T1   U                 13-OCT-15 03.07.01.775236 AM   <<---------- This is the main table, This should have the latest timestamp
T2   I                 13-OCT-15 03.07.01.775953 AM 

2 rows selected.

But for some reason, even after the creation of the 'AFTER' trigger for update, it works as expected. Sense - the main table is not having the last timestamp given

It's OKAY - I told you in my reply earlier. Reread my answer.

could understand somehow that the UPDATE statement is made with earlier

SYSTIMESTAMP until the TRIGGER is assessed and updated so is to have

time stamp prior to the trigger, but this isn't what we wanted. We want to

BEFORE the update)

As I told you before that your UPDATE statement occurs BEFORE the trigger is activated.

Despite what the other speakers have said, it makes NO DIFFERENCE if you use a BEFORE UPDATE or an AFTER UPDATE trigger. Your UPDATE statement runs ALWAYS BEFORE the trigger.

HE has TO - it's your update processing statement that causes the trigger to fire.

Your update statement includes SYSTIMESTAMP. If during the processing of your return to update the value of SYSTIMESTAMP "at this exact time" is captured.

Then your trigger is activated and starts to run. ANY reference to SYSTIMESTAMP that you use in your trigger cannot be earlier than the value of until the trigger was executed. It's IMPOSSIBLE.

The trigger can use the SAME value by referencing: NEW and the column name you store the value. Or the trigger can get its own value that your code is doing.

But the SYSTIMESTAMP value in the trigger will NEVER earlier than the value in your query.

And none of these values can actually be used to tell when the changes are really ENGAGED since the trigger does not work and CAN NOT, to know when, or if, a validation occurs.

Reread my first answer - he explains all this.

Tags: Database

Similar Questions

  • Update KB937287 keep apearing as the only updated, try install many times, but does not work, tried it with the standalone version and it keeps apearing

    Update KB937287 keep apearing that the only update, tried to install a lot of times, but does not work, tried it with the standalone version and it keeps apearing, when I install it does not display an error message, just say that again was successful but when I try to look for more updated it apears again.

    Hi mayortom,

    Thank you for visiting the Microsoft answers Forum.

    You can follow the steps outlined in the article below:

    Troubleshooting Windows Update or Microsoft Update when you are repeatedly offered an update
    http://support.Microsoft.com/kb/910339/

    I hope that helps!

    Thank you and best regards,
    Abdelouahab Microsoft responds to the technical support engineer

  • After the update of Windows CD/DVD drive does not work

    After windows automatically updated on my windows system 8, my CD/DVD drive no longer recognized discs. It will rotate when you close the disc drive as if he tried to recognize and initialize the disc, but then it will do nothing. When you go in my computer it doesn't even say that there is a hard drive available.

    In device manager has a yellow triangle with a '!' in the middle on the DVD/CD drive. When I click on drive properties and check the updates on the disk, it indicates that the drivers are up to date. Drive is MATSHITA DVD-RAM UJ8C0.
    Y at - it a fix for this problem? For some reason my system does not restore automatically save it before the update or the other so I can not on a point system. Help, please.

    Try to remove the GEARAspiWDM entry.

    To remove the GEARAspiWDM entry double-click UpperFilters and, under value data, delete GEARAspiWDM > OK

    Create a system restore point beforehand and restart the computer after.

    However, if you have an application that uses the GEARAspiWDM, like iTunes, just install the latest version of hardware drivers (4.020.5) and that no changes to the registry:

    http://www.GearSoftware.com/support/drivers.php

    Updated speed drivers should also correct the mistake.

  • Synchronize the photos of the Macbook for iPad with 10 items does not work

    I installed 10 items on my new Macbook and copied my photo of the PC Windows Catalog and all is well. But I'm not able to sync pictures with iTunes on my iPad. On the Windows PC, it works fine. Any ideas?

    No, it's something that you can only in windows. You can import photos into iphoto and sync them from there.

  • Time Machine does not work after update of the Sierra

    The time function machine my Mackbook Air 2011 stopped working... it has not been saved since update for Sierra, it only take screenshots every hour, it will perform a backup is no longer on my external HD as before.

    There is no problem with the way it is implemented or the hard drive, it's me that my iMac is working perfectly since the update for Sierra and it's backup via the time machine on the same hard disk.

    It is a hard drive and put in place I was in use for about 5 years with no problems.

    Also since the update for Sierra I noticed that my MacBook Air gets hot and the fans go wild, although there was nothing or performance other than the system is auto.

    I lost the use of my built in camera after the update to El Capitan, and now I've lost the use of time machine... I was wondering if I should go back to Yosemite that everything worked well then!... is this possible?

    Thanks for any help with this!

    Update:-just so you know, time machine is to find the back up ok drive (external hard drive), it then goes to "preparing backup" and that's all, he remains in this preparation save the scene for centuries, after a while it just stops and it is saved all... nothing!

    Also noticed when I checked in Time Machine full backup I have before update for Sierra disappeared, he disappeared, been deleted... I don't know what is happening with it!

    Overall since the update for Sierra my MacBook Air did not work properly, in addition to all that Safari does not load, just to get the wheel spinning, and now (with the demise of my old back ups) it seems I can't go back to a previous state.

    My Mackbook Air took it!... the last update took the camera and really Sierra in... material not compatible with all new software, none of the new features work on my iMac or MacBook Air (only Siri), so a useless upgrade for me really, wish I didn't!

  • I want to record with &lt; alt &gt; &lt; s &gt; in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    Question
    I want to record with < alt > < s > in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    edit, escaped mod < s > in order to avoid the line through question

    A web page can be defined a "accesskey" for an item. Unlike IE/Chrome/Safari, who use the Alt key only, Firefox requires pressing Alt and Shift to activate the element. In other words, try

    ALT + SHIFT + S

    and see if it works.

    I don't know of any way to change this so that the change is not necessary. There may be an add-on?

  • my phone does not work after last update itunes on my phone connection with my pc, it shows only i tunes icon and the application of itune on my pc does not work

    my phone does not work after last update itunes on my phone connection with my pc, it shows only i tunes icon and the application of itune on my pc does not work

    For general advice, see troubleshooting problems with iTunes for Windows updates.

    The steps described in the second case are a guide to remove everything related to iTunes and then rebuild what is often a good starting point, unless the symptoms indicate a more specific approach.

    Review the other boxes and other support documents list to the bottom of the page, in case one of them applies.

    More information area has direct links with the current and recent buildings if you have problems to download, must revert to an older version or want to try the version of iTunes for Windows (64-bit-for old video cards) as a workaround for problems with installation or operation, or compatibility with QuickTime software or a third party.

    Backups of your library and device should be affected by these measures but there are links to backup and recovery advice there.

    Once iTunes to work properly, you should be able to fix your device.

    TT2

  • Updated to 3.6. Extensions and themes stopped working. Updated to 6.0. Still does not work. Returned to 3.6. No dice. Renamed all the extension. Still does not work.

    automatically upgraded to Firefox 3.6. Extensions and themes stopped working. Updated to 6.0. Still does not work. Returned to 3.6.20. Still nothing. Renamed extension files still nothing. Help. everything worked great until the upgrade. Thems like Noia and Adblocker Plus still do not work.

    To help other users find solutions, please return to this Thread and log in to the forum with your user name and password:

    Click on 'resolved' beside the answer above that BETTER resolved your issue

    DO NOT CLICK on 'Solved It' next to this answer

  • Clone Stamp does not work during the operation of frequency separation.

    Spacing of the frequencies for the first time by train.  I finished the layer of tone and now works on the texture, but the clone stamp does not work.  I have the linear light value layer and the stamp tool is set to 'active layer '.  The stamp tool is gray in the Middle, as if I were seeing a "high pass sharpening" layer through the center of it.  Tried to save the doc and the reopening, but none here.  Any other ideas?

    -Jeff

    In fact, I restarted Photoshop and it works properly now.  Thanks for the information on how to best to post a question.  I'll remember that next time!

  • I got a notification of update for adobe CC but it does not work and now the Office does not

    I got a notification of update for adobe CC but it does not work and now the Office does not

    I actually just finished with support on a cat and it was corrected. Thank you.

  • the update of firefox 28 for mac does not, the bar just rotates, I can't get the update

    the update of firefox 28 for mac does not, the bar just rotates, I can't get the update. Thank you

    Hello

    Try to get the full version here:

    Then just install it.

  • Packer of creative cloud in creating a package that I can install do not.  He goes through the motions, download all updates, create setup file, but it does not work despite the fact that there are no errors in the log files

    Packer of creative cloud in creating a package that I can install do not.  He goes through the motions, download all updates, create setup file, but it does not work despite the fact that there are no errors in the log files

    After hitting my head against the desk to repeatedly create packages, try on different computers I have finally found a solution.

    These packages have been copied on an external drive, if I try and install from the external drive, which is a common practice, it fails.

    If I then copy this file pkg from the outside, to the computer I install, then run it, it will to and moved very well.

    That is mind-boggling stupid, because it's rare that you have to copy the file into any computer, it is less always installed off the coast of externally, and many people in the company are pushing on the network and the management of the suites so there is a serious problem in Adobe package manager if this is the case where it cannot manage the Middle installed offshore.

    I hope that if anyone else is having problems so it suits.

  • Impossible to update LR CC ~ my one day to change and nothing work updated my Mac and all LR will do is CRASH!  Need help.  Tried to stop CC and remove the 1.0 file already and who does not work for me.  What can I do?

    Impossible to update LR CC ~ my one day to change and nothing work updated my Mac and all LR will do is CRASH!  Need help.  Tried to stop CC and remove the 1.0 file already and who does not work for me.  What can I do?

    If lr crashes repeatedly, reset preferences.   http://www.lightroomforums.NET/showthread.php?14226-resetting-%28or-trashing-%29-the-light file-Preferences-room

  • Quick Time Player does not work in El Capitan

    Now Quick Time Player does not work properly.  When I click to use it, the only thing it allows me to do is 'click to drag', while he was recording a screen, buttons disappear and the only way I can stop the recording is to go to the menu screen and exit the Quick Time Player.  So annoying!

    It also is not allowing me to change.  When I try to edit my videos and then save it, it says that it cannot save the file.

    None of this makes no sense at all.

    < published by host >

    You have a bad installation, I believe. QT works fine on my systems.

    El Capitan works very well. Sometimes, it is not for lack of the tennis racket. Review download and reinstall OS X El Capitan 10.11.4 Combo Update.

  • Im trying to get off the load free anti virus, but it does not work

    Im trying to get off the load free anti virus, but it does not work

    Im trying to get off the load free anti virus, but it does not work

    Not enough information.

    Of course - you send messages to a Microsoft support forum and one could assume that you mean that you try to download Microsoft Security Essentials, save it to your computer and install it then - but even with this hypothesis - another that knowing you have Windows XP (probably Home edition, but possibly professional or Media Center editions - and probably more than 32-bit not 64 - bit)-we do not like you think we should knowledge.

    Regarding AntiVirus - free are very good: Avira, AVG, Avast

    You could spend ~ 60USD during two years of eSET NOD32 AntiVirus (not more - just AntiVirus.)

    Get one - save on your computer (do not install immediately.)

    Reset...

    After a reboot - install your new product and update after the installation.

    Run a full scan with it.

    Then - just to make sure you started on the right foot...

    Search for malware:

    Download, install, execute, update and perform analyses complete system with the two following applications:

    Remove anything they find. Reboot when necessary. (You can uninstall one or both when finished.)

    Search online with eSet Online Scanner. Remove everything it finds.

    Reset.

Maybe you are looking for