Oracle Edition Based
    Redefinition

       Presentation for




                          http://surachartopun.com
Introduction
•   Surachart Opun
•   Blog: surachartopun.com
•   Oracle ACE
•   OCP 10G/11G and OCE (RAC)
•   Member: OUGTH, IOUG, UKOUG, RAC SIG
•   Twitter: @surachart




                                          http://surachartopun.com
Edition Based Redefinition (EBR)?
• New Feature on 11gR2
• Upgrade an application while it is in use
• Edition object types
   – SYNONYM
   – VIEW
   – All PL/SQL object types:
     (FUNCTION,LIBRARY,PACKAGE and PACKAGE
     BODY,PROCEDURE,TRIGGER,TYPE and TYPE BODY)


                                       http://surachartopun.com
Three New Object Types
• Edition
   – Replacing Edition object types (PL/SQL, synonyms,
     and views)
• Editioning View
   – Table is not an edition type. If you change the
     structure of one or more tables.
• Crossedtion trigger
   – Other users must be able to change data in the
     tables while you are changing their structure
   – If the pre- and post-upgrade applications will be in
     ordinary use at the same time
                                               http://surachartopun.com
Dictionary Views
• Edition
   – dba_editions
   – dba_edition_comments
• Editioning View
   – dba_editioning_views
   – dba_editioning_views_ae (edition_name)
   – dba_editioning_view_cols
• Crossedition Trigger
   – dba_triggers (crossedition)
                                          http://surachartopun.com
What is an Edition?
• A nonschema object type, uniquely identified,
  therefore, by just its name.
• Be able to check in DBA_OBJECTS.

    select * from dba_objects where object_type=
                      ’EDITION’;

• Every database from 11.2 onwards - Least one
  edition.
• The default edition name is ORA$BASE
                                            http://surachartopun.com
• A new edition must be created as the child of an
  existing one.

      create edition version2 as child of ora$base;

• An edition may have no more than one child.

   ORA$BASE <- VERSION2 <- VERSION3 <- VERSION4

create edition version2 as child of ora$base;
create edition version3 as child of version2;
create edition version4 as child of version3;
                                                http://surachartopun.com
SQL> select * from dba_editions;
EDITION_NAME PARENT_EDITION_NAME                           USA
---------------------- ------------------------------ ---
ORA$BASE                                              YES
VERSION4                       VERSION3                   YES
VERSION2                       ORA$BASE                   YES
VERSION3                       VERSION2                   YES




                                                       http://surachartopun.com
• A new database property, DEFAULT_EDITION.

     alter database default edition = Some_Edition

SQL> select PROPERTY_NAME, PROPERTY_VALUE
from database_properties
where PROPERTY_NAME='DEFAULT_EDITION';
PROPERTY_NAME                        PROPERTY_VALUE
------------------------------ --------------------
DEFAULT_EDITION                     ORA$BASE


                                               http://surachartopun.com
• A new alter session command allows the edition that
  a session is using to be changed.

      alter session set edition = Some_Edition

SQL> alter session set edition=version3;
Session altered.
SQL> SELECT SYS_CONTEXT
 ('userenv','current_edition_name') ce FROM DUAL;
CE
----------
VERSION3
                                                 http://surachartopun.com
Edition Privileges
• System Privileges
   – CREATE ANY EDITION
   – ALTER ANY EDITION
   – DROP ANY EDITION
• Object Privileges - USE (not granted by default)
      GRANT USE ON <edition_name> TO <user_name>;

• Roles
  system privileges are granted to the DBA role (only).
• Enable Editioning
      ALTER USER <user_name> ENABLE EDITIONS;

                                                     http://surachartopun.com
Edition Enabled Data Dictionary
               Views
• AUD$ (obj$edition)
• DBA_EDITIONS (edition_name,
  parent_edition_name)
• DBA_OBJECTS (edition_name)
• DBA_OBJECTS_AE (edition_name)
• DBA_SOURCE_AE (edition_name)
• DBA_USERS (editions_enabled)

             • AE = All Editions
                                   http://surachartopun.com
Edition Enabled Data Dictionary
                 Views
•   FGA_LOG$ (obj$edition)
•   UTL_RECOMP_ALL_OBJECTS (edition_name)
•   V$LOGMNR_CONTENTS (edition_name)
•   V$SESSION (session_edition_id)

                 • AE = All Editions




                                        http://surachartopun.com
SQL> SELECT * FROM DBA_EDITIONS;
EDITION_NAME                       PARENT_EDITION_NAME              USA
------------------------------ ------------------------------ ---
 ORA$BASE                                              YES

SQL> CREATE EDITION VERSION2 AS CHILD OF ORA$BASE;
Edition created.

SQL> SELECT * FROM DBA_EDITIONS;
    EDITION_NAME                        PARENT_EDITION_NAME           USA
------------------------------ ------------------------------ ---
ORA$BASE                                              YES
VERSION2                      ORA$BASE                        YES

SQL> ALTER USER DEMO ENABLE EDITIONS;

SQL> GRANT USE ON EDITION VERSION2 TO DEMO;
                                                                          http://surachartopun.com
SQL> connect demo/demo
Connected.

SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL;

CE
--------------------------------------------------------------------------------
ORA$BASE

SQL> create or replace procedure my_procedure
as
Begin
  dbms_output.put_line ( 'I am version 1.0' );
end;
/




                                                                                   http://surachartopun.com
SQL> ALTER SESSION SET EDITION=VERSION2;
Session altered.

SQL> create or replace procedure my_procedure
as
Begin
  dbms_output.put_line ( 'I am version 2.0' );
end;
/

SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM
    DUAL;
CE
--------------------------------------------------------------------------------
ORA$BASE


                                                                       http://surachartopun.com
SQL> exec my_procedure;
I am version 1.0

SQL> ALTER SESSION SET EDITION=VERSION2;
Session altered.

SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM
    DUAL;
CE
--------------------------------------------------------------------------------
VERSION2

SQL> exec my_procedure;
I am version 2.0



                                                                       http://surachartopun.com
What is an Editioning View?
• Editioning view selects a subset of the columns from
  a single base table.
• Use the SQL statement CREATE VIEW with the OR
  REPLACE clause and the keyword EDITIONING.

      CREATE OR REPLACE EDITIONING VIEW …

• Partition-Extended Editioning View Names


                                             http://surachartopun.com
Editioning View Related Data
            Dictionary Views
•   DBA_EDITIONING_VIEW_COLS
•   DBA_EDITIONING_VIEW_COLS_AE
•   DBA_EDITIONING_VIEWS
•   DBA_EDITIONING_VIEWS_AE
•   DBA_ERRORS_AE (editioning_name)
•   DBA_OBJECTS_AE (editioning_name)
•   DBA_VIEWS (editioning_view)

                  • AE = All Editions

                                        http://surachartopun.com
SQL> CREATE EDITIONING VIEW ed01_tab AS SELECT name, tel_num FROM
   ed01_tab_tmp;

SQL> select * from ED01_TAB partition (par_1);
NAME                        TEL_NUM
------------------------------ ----------
TEST1                      1234567
TEST5                      1234567

SQL> CREATE TRIGGER ed01_tab_tri
BEFORE INSERT ON ed01_tab FOR EACH ROW
BEGIN
     null;
END;
/
Trigger created.

                                                       http://surachartopun.com
What is a Crossedition Trigger?
• A new, and special type of trigger specific to
  editioning
• Can only be created on a table (not on an editioning
  view)
• Propagates transactions between editions
• Two types
   – FORWARD
   – REVERSE



                                             http://surachartopun.com
• Crossedition triggers are always created in the child
• Crossedition triggers are temporary—drop them
  after you have made the restructured tables
  available to all users.




                                               http://surachartopun.com
Crossedition Trigger Types
• Forward Crossedition Triggers
   – Only fired by code running in the parent edition
   – Transforms from the old representation to the
     new
• Reverse Crossedition Triggers
   – Only fired by code running in the child edition
   – Transforms from the new representation to the
     old


                                              http://surachartopun.com
Crossedition Trigger Related Data
             Dictionary Views
•   DBA_TRIGGERS
•   DBA_TRIGGER_ORDERING
•   DBA_ERRORS_AE (editioning_name)
•   DBA_OBJECTS_AE (editioning_name)



                  • AE = All Editions



                                        http://surachartopun.com
CREATE TABLE PERSONS (ID NUMBER(10) NOT NULL, FIRST_NAME VARCHAR2(100)
   NOT NULL, LAST_NAME VARCHAR2(100) NOT NULL,EMAIL VARCHAR2(100) NOT
   NULL)
/

RENAME persons TO persons_tab;

CREATE EDITIONING VIEW persons AS
SELECT id, first_name AS firstname, last_name AS lastname, email FROM persons_tab;

create sequence persons_seq;




                                                                    http://surachartopun.com
CREATE OR REPLACE TRIGGER persons_bi_trg
BEFORE INSERT ON persons FOR EACH ROW
BEGIN
 :new.id := persons_seq.nextval;
END;
/

insert into persons values (null,'Somchai','A.','somchai@test.com');
commit;

ALTER TABLE persons_tab ADD (email_recipient VARCHAR2(100),email_domain
   VARCHAR2(100));

SQL> select * from persons;
      ID FIRSTNAME             LASTNAME             EMAIL
---------- --------------- --------------- --------------------
       1 Somchai            A.           somchai@test.com

                                                                       http://surachartopun.com
alter session set edition=VERSION2;

CREATE TRIGGER persons_fc_trg
BEFORE INSERT OR UPDATE ON persons_tab FOR EACH ROW
FORWARD CROSSEDITION
DISABLE
BEGIN
:new.email_recipient :=
   regexp_substr(:new.email,'(.*)@',1,1,NULL,1);
:new.email_domain :=
regexp_substr(:new.email,'@(.*)',1,1,NULL,1);
END;
/




                                                      http://surachartopun.com
column CE for a10
SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL;

CREATE OR REPLACE EDITIONING VIEW persons AS
SELECT id, first_name AS firstname, last_name AS
   lastname,email_recipient,email_domain FROM persons_tab;

SQL> select * from persons;

      ID FIRSTNAME             LASTNAME             EMAIL_RECIPIENT EMAIL_DOMAIN
---------- --------------- --------------- -------------------- --------------------
       1 Somchai            A.




                                                                               http://surachartopun.com
ALTER TRIGGER persons_fc_trg ENABLE;

DECLARE
c INTEGER;
r INTEGER;
BEGIN
c := dbms_sql.open_cursor;
dbms_sql.parse(
c => c,
statement => 'UPDATE persons SET email_domain = email_domain',language_flag =>
     dbms_sql.native,
apply_crossedition_trigger => 'persons_fc_trg');
r := dbms_sql.execute(c);
dbms_sql.close_cursor(c);
COMMIT;
END;
/


                                                                  http://surachartopun.com
SQL> select * from persons;
      ID FIRSTNAME             LASTNAME             EMAIL_RECIPIENT EMAIL_DOMAIN
---------- --------------- --------------- -------------------- --------------------
       1 Somchai            A.           somchai               test.com

---TEST FORWARD ---

alter session set edition=ORA$BASE;

update persons set email='surachart@gmail.com' where id=1;
commit;

SQL> select * from persons;
      ID FIRSTNAME             LASTNAME             EMAIL
---------- --------------- --------------- -------------------------
       1 Somchai            A.           surachart@gmail.com



                                                                               http://surachartopun.com
alter session set edition=version2;

SQL> select * from persons;
      ID FIRSTNAME             LASTNAME             EMAIL_RECIPIENT EMAIL_DOMAIN
---------- --------------- --------------- -------------------- --------------------
       1 Somchai            A.           surachart             gmail.com




                                                                               http://surachartopun.com
---TEST REVERSE---

alter session set edition=version2;

CREATE TRIGGER persons_rc_trg
BEFORE INSERT OR UPDATE ON persons_tab FOR EACH ROW
 REVERSE CROSSEDITION
 DISABLE
 BEGIN
 :new.email := :new.email_recipient || '@' || :new.email_domain;
END;
/

alter trigger persons_rc_trg enable;

insert into persons values (null,'Surachart','O.','surachart',‘test.com');
commit;



                                                                             http://surachartopun.com
SQL> select * from persons;
      ID FIRSTNAME             LASTNAME             EMAIL_RECIPIENT EMAIL_DOMAIN
---------- --------------- --------------- -------------------- --------------------
       1 Somchai           A.           surachart             gmail.com
       2 Surachart         O.            surachart             test.com

alter session set edition=ORA$BASE;

SQL> select * from persons;
      ID FIRSTNAME             LASTNAME             EMAIL
---------- --------------- --------------- ------------------------------
       1 Somchai           A.           surachart@gmail.com
       2 Surachart         O.            surachart@test.com




                                                                            http://surachartopun.com
Learn More…
• Oracle Documents (E11882_01)




                                 http://surachartopun.com
Learn More..
• Tom Kyte on Edition Based Redefinition




                                       http://surachartopun.com
Learn More…
• Bryn Llewellyn's White Paper




                                 http://surachartopun.com
Learn More…
• Morgan Library www.morganslibrary.org




                                     http://surachartopun.com
Learn More…
• IOUG – Select Journal




                            http://surachartopun.com
Q&A



      http://surachartopun.com
THANK YOU




            http://surachartopun.com

Basic - Oracle Edition Based Redefinition Presentation

  • 1.
    Oracle Edition Based Redefinition Presentation for http://surachartopun.com
  • 2.
    Introduction • Surachart Opun • Blog: surachartopun.com • Oracle ACE • OCP 10G/11G and OCE (RAC) • Member: OUGTH, IOUG, UKOUG, RAC SIG • Twitter: @surachart http://surachartopun.com
  • 3.
    Edition Based Redefinition(EBR)? • New Feature on 11gR2 • Upgrade an application while it is in use • Edition object types – SYNONYM – VIEW – All PL/SQL object types: (FUNCTION,LIBRARY,PACKAGE and PACKAGE BODY,PROCEDURE,TRIGGER,TYPE and TYPE BODY) http://surachartopun.com
  • 4.
    Three New ObjectTypes • Edition – Replacing Edition object types (PL/SQL, synonyms, and views) • Editioning View – Table is not an edition type. If you change the structure of one or more tables. • Crossedtion trigger – Other users must be able to change data in the tables while you are changing their structure – If the pre- and post-upgrade applications will be in ordinary use at the same time http://surachartopun.com
  • 5.
    Dictionary Views • Edition – dba_editions – dba_edition_comments • Editioning View – dba_editioning_views – dba_editioning_views_ae (edition_name) – dba_editioning_view_cols • Crossedition Trigger – dba_triggers (crossedition) http://surachartopun.com
  • 6.
    What is anEdition? • A nonschema object type, uniquely identified, therefore, by just its name. • Be able to check in DBA_OBJECTS. select * from dba_objects where object_type= ’EDITION’; • Every database from 11.2 onwards - Least one edition. • The default edition name is ORA$BASE http://surachartopun.com
  • 7.
    • A newedition must be created as the child of an existing one. create edition version2 as child of ora$base; • An edition may have no more than one child. ORA$BASE <- VERSION2 <- VERSION3 <- VERSION4 create edition version2 as child of ora$base; create edition version3 as child of version2; create edition version4 as child of version3; http://surachartopun.com
  • 8.
    SQL> select *from dba_editions; EDITION_NAME PARENT_EDITION_NAME USA ---------------------- ------------------------------ --- ORA$BASE YES VERSION4 VERSION3 YES VERSION2 ORA$BASE YES VERSION3 VERSION2 YES http://surachartopun.com
  • 9.
    • A newdatabase property, DEFAULT_EDITION. alter database default edition = Some_Edition SQL> select PROPERTY_NAME, PROPERTY_VALUE from database_properties where PROPERTY_NAME='DEFAULT_EDITION'; PROPERTY_NAME PROPERTY_VALUE ------------------------------ -------------------- DEFAULT_EDITION ORA$BASE http://surachartopun.com
  • 10.
    • A newalter session command allows the edition that a session is using to be changed. alter session set edition = Some_Edition SQL> alter session set edition=version3; Session altered. SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL; CE ---------- VERSION3 http://surachartopun.com
  • 11.
    Edition Privileges • SystemPrivileges – CREATE ANY EDITION – ALTER ANY EDITION – DROP ANY EDITION • Object Privileges - USE (not granted by default) GRANT USE ON <edition_name> TO <user_name>; • Roles system privileges are granted to the DBA role (only). • Enable Editioning ALTER USER <user_name> ENABLE EDITIONS; http://surachartopun.com
  • 12.
    Edition Enabled DataDictionary Views • AUD$ (obj$edition) • DBA_EDITIONS (edition_name, parent_edition_name) • DBA_OBJECTS (edition_name) • DBA_OBJECTS_AE (edition_name) • DBA_SOURCE_AE (edition_name) • DBA_USERS (editions_enabled) • AE = All Editions http://surachartopun.com
  • 13.
    Edition Enabled DataDictionary Views • FGA_LOG$ (obj$edition) • UTL_RECOMP_ALL_OBJECTS (edition_name) • V$LOGMNR_CONTENTS (edition_name) • V$SESSION (session_edition_id) • AE = All Editions http://surachartopun.com
  • 14.
    SQL> SELECT *FROM DBA_EDITIONS; EDITION_NAME PARENT_EDITION_NAME USA ------------------------------ ------------------------------ --- ORA$BASE YES SQL> CREATE EDITION VERSION2 AS CHILD OF ORA$BASE; Edition created. SQL> SELECT * FROM DBA_EDITIONS; EDITION_NAME PARENT_EDITION_NAME USA ------------------------------ ------------------------------ --- ORA$BASE YES VERSION2 ORA$BASE YES SQL> ALTER USER DEMO ENABLE EDITIONS; SQL> GRANT USE ON EDITION VERSION2 TO DEMO; http://surachartopun.com
  • 15.
    SQL> connect demo/demo Connected. SQL>SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL; CE -------------------------------------------------------------------------------- ORA$BASE SQL> create or replace procedure my_procedure as Begin dbms_output.put_line ( 'I am version 1.0' ); end; / http://surachartopun.com
  • 16.
    SQL> ALTER SESSIONSET EDITION=VERSION2; Session altered. SQL> create or replace procedure my_procedure as Begin dbms_output.put_line ( 'I am version 2.0' ); end; / SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL; CE -------------------------------------------------------------------------------- ORA$BASE http://surachartopun.com
  • 17.
    SQL> exec my_procedure; Iam version 1.0 SQL> ALTER SESSION SET EDITION=VERSION2; Session altered. SQL> SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL; CE -------------------------------------------------------------------------------- VERSION2 SQL> exec my_procedure; I am version 2.0 http://surachartopun.com
  • 18.
    What is anEditioning View? • Editioning view selects a subset of the columns from a single base table. • Use the SQL statement CREATE VIEW with the OR REPLACE clause and the keyword EDITIONING. CREATE OR REPLACE EDITIONING VIEW … • Partition-Extended Editioning View Names http://surachartopun.com
  • 19.
    Editioning View RelatedData Dictionary Views • DBA_EDITIONING_VIEW_COLS • DBA_EDITIONING_VIEW_COLS_AE • DBA_EDITIONING_VIEWS • DBA_EDITIONING_VIEWS_AE • DBA_ERRORS_AE (editioning_name) • DBA_OBJECTS_AE (editioning_name) • DBA_VIEWS (editioning_view) • AE = All Editions http://surachartopun.com
  • 20.
    SQL> CREATE EDITIONINGVIEW ed01_tab AS SELECT name, tel_num FROM ed01_tab_tmp; SQL> select * from ED01_TAB partition (par_1); NAME TEL_NUM ------------------------------ ---------- TEST1 1234567 TEST5 1234567 SQL> CREATE TRIGGER ed01_tab_tri BEFORE INSERT ON ed01_tab FOR EACH ROW BEGIN null; END; / Trigger created. http://surachartopun.com
  • 21.
    What is aCrossedition Trigger? • A new, and special type of trigger specific to editioning • Can only be created on a table (not on an editioning view) • Propagates transactions between editions • Two types – FORWARD – REVERSE http://surachartopun.com
  • 22.
    • Crossedition triggersare always created in the child • Crossedition triggers are temporary—drop them after you have made the restructured tables available to all users. http://surachartopun.com
  • 23.
    Crossedition Trigger Types •Forward Crossedition Triggers – Only fired by code running in the parent edition – Transforms from the old representation to the new • Reverse Crossedition Triggers – Only fired by code running in the child edition – Transforms from the new representation to the old http://surachartopun.com
  • 24.
    Crossedition Trigger RelatedData Dictionary Views • DBA_TRIGGERS • DBA_TRIGGER_ORDERING • DBA_ERRORS_AE (editioning_name) • DBA_OBJECTS_AE (editioning_name) • AE = All Editions http://surachartopun.com
  • 25.
    CREATE TABLE PERSONS(ID NUMBER(10) NOT NULL, FIRST_NAME VARCHAR2(100) NOT NULL, LAST_NAME VARCHAR2(100) NOT NULL,EMAIL VARCHAR2(100) NOT NULL) / RENAME persons TO persons_tab; CREATE EDITIONING VIEW persons AS SELECT id, first_name AS firstname, last_name AS lastname, email FROM persons_tab; create sequence persons_seq; http://surachartopun.com
  • 26.
    CREATE OR REPLACETRIGGER persons_bi_trg BEFORE INSERT ON persons FOR EACH ROW BEGIN :new.id := persons_seq.nextval; END; / insert into persons values (null,'Somchai','A.','somchai@test.com'); commit; ALTER TABLE persons_tab ADD (email_recipient VARCHAR2(100),email_domain VARCHAR2(100)); SQL> select * from persons; ID FIRSTNAME LASTNAME EMAIL ---------- --------------- --------------- -------------------- 1 Somchai A. somchai@test.com http://surachartopun.com
  • 27.
    alter session setedition=VERSION2; CREATE TRIGGER persons_fc_trg BEFORE INSERT OR UPDATE ON persons_tab FOR EACH ROW FORWARD CROSSEDITION DISABLE BEGIN :new.email_recipient := regexp_substr(:new.email,'(.*)@',1,1,NULL,1); :new.email_domain := regexp_substr(:new.email,'@(.*)',1,1,NULL,1); END; / http://surachartopun.com
  • 28.
    column CE fora10 SELECT SYS_CONTEXT ('userenv','current_edition_name') ce FROM DUAL; CREATE OR REPLACE EDITIONING VIEW persons AS SELECT id, first_name AS firstname, last_name AS lastname,email_recipient,email_domain FROM persons_tab; SQL> select * from persons; ID FIRSTNAME LASTNAME EMAIL_RECIPIENT EMAIL_DOMAIN ---------- --------------- --------------- -------------------- -------------------- 1 Somchai A. http://surachartopun.com
  • 29.
    ALTER TRIGGER persons_fc_trgENABLE; DECLARE c INTEGER; r INTEGER; BEGIN c := dbms_sql.open_cursor; dbms_sql.parse( c => c, statement => 'UPDATE persons SET email_domain = email_domain',language_flag => dbms_sql.native, apply_crossedition_trigger => 'persons_fc_trg'); r := dbms_sql.execute(c); dbms_sql.close_cursor(c); COMMIT; END; / http://surachartopun.com
  • 30.
    SQL> select *from persons; ID FIRSTNAME LASTNAME EMAIL_RECIPIENT EMAIL_DOMAIN ---------- --------------- --------------- -------------------- -------------------- 1 Somchai A. somchai test.com ---TEST FORWARD --- alter session set edition=ORA$BASE; update persons set email='surachart@gmail.com' where id=1; commit; SQL> select * from persons; ID FIRSTNAME LASTNAME EMAIL ---------- --------------- --------------- ------------------------- 1 Somchai A. surachart@gmail.com http://surachartopun.com
  • 31.
    alter session setedition=version2; SQL> select * from persons; ID FIRSTNAME LASTNAME EMAIL_RECIPIENT EMAIL_DOMAIN ---------- --------------- --------------- -------------------- -------------------- 1 Somchai A. surachart gmail.com http://surachartopun.com
  • 32.
    ---TEST REVERSE--- alter sessionset edition=version2; CREATE TRIGGER persons_rc_trg BEFORE INSERT OR UPDATE ON persons_tab FOR EACH ROW REVERSE CROSSEDITION DISABLE BEGIN :new.email := :new.email_recipient || '@' || :new.email_domain; END; / alter trigger persons_rc_trg enable; insert into persons values (null,'Surachart','O.','surachart',‘test.com'); commit; http://surachartopun.com
  • 33.
    SQL> select *from persons; ID FIRSTNAME LASTNAME EMAIL_RECIPIENT EMAIL_DOMAIN ---------- --------------- --------------- -------------------- -------------------- 1 Somchai A. surachart gmail.com 2 Surachart O. surachart test.com alter session set edition=ORA$BASE; SQL> select * from persons; ID FIRSTNAME LASTNAME EMAIL ---------- --------------- --------------- ------------------------------ 1 Somchai A. surachart@gmail.com 2 Surachart O. surachart@test.com http://surachartopun.com
  • 34.
    Learn More… • OracleDocuments (E11882_01) http://surachartopun.com
  • 35.
    Learn More.. • TomKyte on Edition Based Redefinition http://surachartopun.com
  • 36.
    Learn More… • BrynLlewellyn's White Paper http://surachartopun.com
  • 37.
    Learn More… • MorganLibrary www.morganslibrary.org http://surachartopun.com
  • 38.
    Learn More… • IOUG– Select Journal http://surachartopun.com
  • 39.
    Q&A http://surachartopun.com
  • 40.
    THANK YOU http://surachartopun.com