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

Post on 17-Jun-2015

2282 Views

Category:

Technology

7 Downloads

Preview:

Click to see full reader

Transcript

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

Roel Hartman

© Logica 2010. All rights reserved

EBR and APEX?

Sorry, you can’t do it...

Questions?

John’s suggestion....

© 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

© Logica 2010. All rights reserved

Tom Kyte says:

Unplanned Downtime

Planned Downtime

No. 14© Logica 2010. All rights reserved

Planned Downtime

•Application Upgrade• Create objects

• Replace objects

• Drop objects

• Recompilation

The Case

© 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

No. 17© Logica 2010. All rights reserved

• Edition

• Schema

• Object Type

• Object Name

Session runs in the context of an Edition

Parallel Universes

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>

SQL> select * from all_editions;

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

SQL>

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

No. 21© Logica 2010. All rights reserved

ORA$BASEHR OE

HR_RELEASE2

OE_RELEASE2

HR’

OE’

One Child – One Parent

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

ORA$BASE

HR_RELEASE2

PL/SQL (A)

PL/SQL (B)

Table X Table Y

PL/SQL (A)

PL/SQL (B)

PL/SQL (B’)

© 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

© Logica 2010. All rights reserved

No. 26© Logica 2010. All rights reserved

Editioning View

•Data is the same

•View is different

•Depends on your position / edition

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’

© 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?

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”

© 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

© 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

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

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

© 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

© 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

© Logica 2010. All rights reserved

EBR and APEX - 1

•ALTER SESSION SET EDITION

•DBMS_SESSION.SET_EDITION_DEFERRED

•Session Pooling

© 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

© 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

© Logica 2010. All rights reserved

EBR and APEX – Cool demo

© Logica 2010. All rights reserved

SQLDeveloper support

© 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

© Logica 2010. All rights reserved

•Short time

• Long(er) time

•Only for a specific group

•SaaS environment

Parallel Application Versions

© 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

© 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

© 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

Question Time

My blog : http://roelhartman.blogspot.comMy e-mail : roel.hartman@logica.com

top related