Oracle Crossedition Triggers
Version 12.1.0.2

General Information
Library Note Morgan's Library Page Header
The Library is currently in the process of being upgraded from Oracle Database Version 12.1.0.2 to 12.2.0.1. Demos are being upgraded to reflect the new Container paradigm as well as EBR (Edition Based Redefinition) and may contain references to CDBs, PDBs, and other objects you may not be familiar with such as CDB_OBJECTS_AE: Welcome to 12c.

Also important ... there are rumors on the web about SPARC and Solaris being discontinued. Welcome to the age of fake news. There is absolutely not a byte of truth to these irresponsible rumors.
Data Dictionary Objects
ALL_TRIGGERS DBA_TRIGGERS TRIGGER$
DBA_ERRORS_AE DBA_TRIGGER_ORDERING USER_TRIGGERS
DBA_OBJECTS_AE    
System Privileges
ALTER ANY TRIGGER CREATE TRIGGER DROP ANY TRIGGER
CREATE ANY TRIGGER    
 
CREATE
Create Forward Editioning Trigger CREATE OR REPLACE TRIGGER <trigger_name>
BEFORE <INSERT OR UPDATE OR DELETE>
ON <table_name>
FOR EACH ROW
<FORWARD CROSSEDITION [FOLLOWS <trigger_name>] |
 REVERSE CROSSEDITION [PRECEDES <trigger_name>]>
<ENABLE | DISABLE>
BEGIN
  <trigger_body_code>
END;
/
CREATE OR REPLACE TRIGGER Contacts_Fwd_Xed
BEFORE INSERT OR UPDATE ON Contacts_Table
FOR EACH ROW
FORWARD CROSSEDITION
DISABLE
BEGIN
  Set_First_And_Last_Name(:NEW.Name_1, :NEW.First_Name_2, :NEW.Last_Name_2);
  Set_Country_Code_And_Phone_No(:NEW.Phone_Number_1, :NEW.Country_Code_2, :NEW.Phone_Number_2);
END Contacts_Fwd_Xed;
/
Create Reverse Editioning Trigger CREATE OR REPLACE TRIGGER Contacts_Rvrs_Xed
BEFORE INSERT OR UPDATE ON Contacts_Table
FOR EACH ROW
REVERSE CROSSEDITION
DISABLE
BEGIN
  :NEW.Name_1 := :NEW.Last_Name_2||', '||:NEW.First_Name_2;
  :NEW.Phone_Number_1 :=
     CASE :New.Country_Code_2 WHEN '+1' THEN
       REPLACE(:NEW.Phone_Number_2, '-', '.')
     ELSE
       '011.'||LTRIM(:NEW.Country_Code_2, '+')||'.'|| REPLACE(:NEW.Phone_Number_2, '-', '.')
     END;
END Contacts_Rvrs_Xed;
/
FOLLOWS CLAUSE CREATE OR REPLACE TRIGGER follows_test
BEFORE INSERT OR UPDATE ON person_tab
FOR EACH ROW
FORWARD CROSSEDITION
FOLLOWS ebradmin.person_fwd_xed

ENABLE
BEGIN
  dbms_output.put_line('FOLLOWS_TEST');
END person_fwd_xed;
/
PRECEDES CLAUSE CREATE OR REPLACE TRIGGER precedes_test
BEFORE INSERT OR UPDATE ON person_tab
FOR EACH ROW
REVERSE CROSSEDITION
PRECEDES ebradmin.person_rev_xed

ENABLE
BEGIN
  dbms_output.put_line('PRECEDES_TEST');
END person_rev_xed;
/
 
ALTER
Alter Editioning Trigger Enable or Disable ALTER TRIGGER <trigger_name> <ENABLE | DISABLE>;
SELECT trigger_name, status
FROM user_triggers;

ALTER TRIGGER Contacts_Fwd_Xed DISABLE;

SELECT trigger_name, status
FROM user_triggers;

ALTER TRIGGER Contacts_Fwd_Xed ENABLE;

SELECT trigger_name, status
FROM user_triggers;
 
DROP
Drop Editioning Trigger DROP TRIGGER <trigger_name>;
DROP TRIGGER Contacts_Fwd_Xed;

Related Topics
DBMS_EDITIONS_UTILITIES
DDL Event Triggers
Editions
Editioning Demo 1
Editioning Demo 2
Editioning Demo 3
Editioning Demo 4
Editioning Demo 5
Editioning Demo 6
Editioning Demo 7
Editioning Views
Instead Of Triggers
SYS_CONTEXT Function
System Event Triggers
Table Triggers
What's New In 12cR1
What's New In 12cR2

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2017 Daniel A. Morgan All Rights Reserved