Created
May 7, 2016 19:53
-
-
Save ajin/20589271e9858538eef6560722556c48 to your computer and use it in GitHub Desktop.
Default Oracle trigger for insert and update statement
This file contains 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 "BIU_<TABLE_NAME>" | |
before insert or update on "<TABLE_NAME>" | |
for each row | |
begin | |
if inserting and :new.id is null then | |
select "<TABLE_NAME>_ID_SEQ".nextval into :NEW."ID" from sys.dual; | |
end if; | |
if inserting then | |
:new.created_by := nvl(apex_application.g_user,USER); | |
:new.created_date := localtimestamp; | |
:new.last_modified_by := nvl(apex_application.g_user,USER); | |
:new.last_modified_date := localtimestamp; | |
end if; | |
if updating then | |
:new.last_modified_by := nvl(apex_application.g_user,USER); | |
:new.last_modified_date := localtimestamp; | |
end if; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment