Oracle Database - Trigger

About

trigger in Oracle.

Example

Trigger used in apex

create or replace trigger myTableTrigger
before insert or update on myTable
for each row
begin
    if inserting then
        if :new.myPk is null then
          select mySequence.nextval into :new.myPk from dual;
        end if;
        :new.created_on := systimestamp;
        :new.created_by := nvl(v('APP_USER'),nvl(sys_context('userenv','os_user'),user));
		:new.
    elsif updating then
         :new.updated_on := systimestamp;
         :new.updated_by := nvl(v('APP_USER'),nvl(sys_context('userenv','os_user'),user));
    end if;
end;
/

Documentation / Reference


Powered by ComboStrap