Created
January 2, 2013 20:23
-
-
Save phantom42/4437655 to your computer and use it in GitHub Desktop.
template code to deal with the following discovered behavior
-table rows were being updated without explicitly setting the updatedby value
-:NEW reads the existing value of background_inv.updatedby and uses that to insert into the history table
-this would create history logs associated with the incorrect user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE TRIGGER TIUD_BACKGROUND_INV | |
AFTER DELETE OR INSERT OR UPDATE | |
ON BACKGROUND_INV REFERENCING NEW AS NEW OLD AS OLD | |
FOR EACH ROW | |
DECLARE | |
v_new_updated_by := background_inv.updatedby%type ; | |
BEGIN | |
IF updating THEN | |
IF ( UPDATING('UPDATEDBY') ) | |
THEN | |
v_new_updated_by := :NEW.updatedby; | |
ELSE | |
v_new_updated_by := null; | |
END IF; | |
-- log history table with v_new_updated_by | |
END IF ; | |
END ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment