Top Banner
Tales from a Parallel Universe: Using 11gR2’s Edition Based Redefinitions (in APEX) Roel Hartman
44

Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

Jun 17, 2015

Download

Technology

Roel Hartman
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

Tales from a Parallel Universe:Using 11gR2’s Edition Based Redefinitions (in APEX)

Roel Hartman

Page 2: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

EBR and APEX?

Sorry, you can’t do it...

Questions?

John’s suggestion....

Page 3: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

Who am I?

• Oracle since v5, Forms 2.3, Case*Designer etc

• Presenter at UKOUG (3x), OOW (3x), ODTUG (2x)

ROELHARTMAN.BLOGSPOT.COM

No. 3

Page 4: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

Tom Kyte says:

Page 5: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX
Page 6: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX
Page 7: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX
Page 8: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX
Page 9: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX
Page 10: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

Unplanned Downtime

Page 11: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

Planned Downtime

Page 12: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

No. 14© Logica 2010. All rights reserved

Planned Downtime

•Application Upgrade• Create objects

• Replace objects

• Drop objects

• Recompilation

The Case

Page 13: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX
Page 14: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

Keep the Shop open

1. Prepare new Release

2. Cut over

Version 1

Version 2 1

1

2Boo

Randall

Sulley

+ 2

Page 15: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

No. 17© Logica 2010. All rights reserved

• Edition

• Schema

• Object Type

• Object Name

Session runs in the context of an Edition

Parallel Universes

Page 16: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

SQL> ALTER USER HR ENABLE EDITIONS;

USER ALTERED.

SQL> ALTER USER HR DISABLE EDITIONS;ALTER USER HR DISABLE EDITIONS *ERROR at line 1:ORA-00922: missing or invalid option

SQL>

Page 17: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

SQL> select * from all_editions;

EDITION_NAME PARENT_EDITION_NAME USA------------ ------------------- ---ORA$BASE YES

SQL>

Page 18: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

SQL> CREATE EDITION HR_RELEASE2 AS CHILD OF ORA$BASE;

Edition created.

SQL> CREATE EDITION OE_RELEASE2 AS CHILD OF ORA$BASE;CREATE EDITION OE_RELEASE2 AS CHILD OF ORA$BASE;*ERROR at line 1:ORA-38807: Implementation restriction: an edition can have only one child

Page 19: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

No. 21© Logica 2010. All rights reserved

ORA$BASEHR OE

HR_RELEASE2

OE_RELEASE2

HR’

OE’

One Child – One Parent

Page 20: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

No. 22© Logica 2010. All rights reserved

Editionable•PL/SQL Objects

• Packages

• Procedures

• Functions

• Triggers

•Views

•Synonyms

•Types

Not everything is editionable...

Not Editionable•Tables

•Materialized Views

•DB Links

Page 21: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

ORA$BASE

HR_RELEASE2

PL/SQL (A)

PL/SQL (B)

Table X Table Y

PL/SQL (A)

PL/SQL (B)

PL/SQL (B’)

Page 22: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

• “Instead-of-table”

•Only one table in the from clause

•No expressions, only columns

•Can have “regular” table triggers

•Same execution plan

Editioning Views are the new tables

•Editioning Views are Editionable....

Editioning View

Page 23: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

Page 24: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

No. 26© Logica 2010. All rights reserved

Editioning View

•Data is the same

•View is different

•Depends on your position / edition

Page 25: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

ORA$BASE

HR_RELEASE2

PL/SQL (A)

PL/SQL (B)

Table X_t Table Y_t

PL/SQL (A)

PL/SQL (B)

PL/SQL (B’)

Editioning View X

Editioning View Y

Editioning View Y’

Page 26: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•Old situation : One column NAME

•New situation : FIRST_NAME / LAST_NAME

•Cross Edition Triggers• Forward• Reverse• Only on a Table• Editionable • In the new edition!

How to handle Table changes?

Page 27: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

RELEASE 2ORA$BASE

NAME FIRST_NAME LAST_NAME

Session A Session B

RELEASE 3

Session C

Forward CrossEdition

Trigger

Reverse CrossEdition

Trigger

Cross Edition Triggers

“split” “concat”

Page 28: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

Prepare your Application

1Rename

your tables

2Create

editioning views

3Reroute

privileges

4Recreate triggers

5Recompile

PL/SQL

6Apply VPD

policies

Your last Planned Downtime

Page 29: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•grant use on edition to <user>

•alter database default edition=<x>

•alter session set edition=<x>

•dbms_session.set_edition_deferred( <x> )

• sys.dbms_sys_sql.parse (_as_user)

• sys_context

•SQL*Plus : show edition

Opening up an Edition

Page 30: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

SQL> GRANT USE ON EDITION HR_RELEASE2 TO SCOTT;

Grant succeeded.

SQL> CONNECT SCOTT/TIGERConnected.SQL> select sys_context('userenv', 'current_edition_name') current_edition_name from dual;

CURRENT_EDITION_NAME--------------------ORA$BASE

Page 31: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

SQL> ALTER SESSION SET EDITION=HR_RELEASE2;

Session altered.

SQL> select sys_context('userenv', 'current_edition_name') current_edition_name from dual;

CURRENT_EDITION_NAME--------------------HR_RELEASE2

Page 32: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•Rolling back an upgrade

•Retiring an Edition

•Only the root or a leaf

•No objects are inherited (anymore)

•Not currently in use

•Not the DB default edition

•Recompile objects (reuse settings)

Dropping an Edition

Page 33: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

• *_EDITIONS

• *_EDITION_COMMENTS

• *_VIEWS_AE

• *_SOURCE_AE

• *_OBJECTS_AE

• *_ERRORS_AE

• *_EDITIONING_VIEWS_AE

• *_EDITIONING_VIEW_COLS_AE

•DBMS_EDITIONS_UTILITIES.SET_EDITIONING_VIEWS_READ_ONLY

•DBMS_SESSION.SET_EDITION_DEFERRED( <EDITION_NAME> )

New Database Stuff

Page 34: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

EBR and APEX - 1

•ALTER SESSION SET EDITION

•DBMS_SESSION.SET_EDITION_DEFERRED

•Session Pooling

Page 35: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•dbms_epg.set_dad_attribute('APEX', 'database-edition', 'HR_RELEASE2');

• in dads.conf : PlsqlDatabaseEdition*

•apex_util.set_edition

• sets CURRENT_EDITION

EBR and APEX - 2

Syntax error on line 48 of /home/oracle/OraHome_1/Apache/modplsql/conf/dads.conf:Invalid command 'PlsqlDatabaseEdition', perhaps mis-spelled or defined by a module not included in the server

Page 36: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•Build on – views on - Editioning Views

•Four (!) -tier architecture

•Edition your Views or PL/SQL Functions

•Use Authorization Schemes

EBR and APEX - 3

Table

Editioning View

(Regular) View

UI / APEX

Page 37: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

EBR and APEX – Cool demo

Page 38: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

SQLDeveloper support

Page 39: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•Applications never never never access tables

•Application sets the edition

•Alter DAD’s edition (EPG only)!

Be aware!!

•Dropping objects drops inheritance

•No branching

Best Practices

Page 40: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•Short time

• Long(er) time

•Only for a specific group

•SaaS environment

Parallel Application Versions

Page 41: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•Different versions in the same schema

•No more planned downtime!

•Ease of maintenance

• Less redo

• Less risk

•So saving $$$

Summary & conclusions

Page 42: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•Edition-Based Redefinition: Testing Live Application Upgrades (Without Actually Being Live) - Ms Melanie Caffrey

Today at 14:15

Other sessions @UKOUG

Page 43: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

© Logica 2010. All rights reserved

•Tom Kyte column(s) in Oracle Magazine Jan/Feb 2010 (http://www.oracle.com/technology/oramag/oracle/10-jan/o10asktom.html)

•Bryn's Whitepaper "Edition-Based Redefinition a new capability in Oracle Database 11g Release 2 to support online application upgrade". July 2009 (http://www.oracle.com/technology/deploy/availability/pdf/edition_based_redefinition.pdf)

•Documentation in "Oracle Database Advanced Application Developer's Guide 11g Release 2" (http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_editions.htm).

References

Page 44: Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

Question Time

My blog : http://roelhartman.blogspot.comMy e-mail : [email protected]