Using Thick Database Principles to Leverage Oracle SQL and PL/SQL Part III:

Similar documents
Using Thick Database Principles to Leverage Oracle SQL and PL/SQL Part I:

Design Modernization Case Study: Applying Mobile App Design Principles to the UTOUG Website

You CAN Judge a Book by Its Cover: Modern User Interface Design Principles

Don t get it right, just get it written.

If you wish to make an improved product, you must already be engaged in making an inferior one.

Agenda Birds Do It: Migrating Forms to Java EE Web A Case Study

Just Get it Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

Just Get it Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

FILE XML DATABASE DEVELOPERS ORACLE 11G MANUAL EBOOK

The Tie That Binds: An Introduction to ADF Bindings

The End of the Beginning: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

Unraveling the Mysteries of J2EE Web Application Communications

Both Sides Now: DevOps and Agile in Oracle Developer Cloud Service for Fusion Middleware Developers

Table of Contents. Oracle SQL PL/SQL Training Courses

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL)

The Arrangement of the Screens: Introduction to Layout in ADF Faces

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL)

Achieving the Perfect Layout with ADF Faces RC

RMOUG Training Days 2018

Extend EBS Using Applications Express

Just Get it Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002.

Build a Mobile App in 60 Minutes with MAF

Database Programming with SQL

Mobilize Your Users Now with Oracle Mobile Application Framework (MAF)

Introduction to SQL/PLSQL Accelerated Ed 2

J2EE for Oracle Technologists

Oracle Database: Program with PL/SQL

Oracle Database: Introduction to SQL/PLSQL Accelerated

And Answers In Oracle Pl Sql

Fast Track Model Based Design and Development with Oracle9i Designer. An Oracle White Paper August 2002

Build a Mobile App in 60 Minutes with MAF

The NoPlsql and Thick Database Paradigms

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

Creating and Managing Tables Schedule: Timing Topic

Oracle Forms and Oracle APEX The Odd Couple

ORACLE PL/SQL PERFORMANCE TUNING TIPS & TECHNIQUES BY MICHAEL ROSENBLUM, PAUL DORSEY

Apex 5.1 Interactive Grid and Other New features

Build Mobile Cloud Apps Effectively Using Oracle Mobile Cloud Services (MCS)

Oracle WebLogic Server Application Security

Oracle Database: SQL and PL/SQL Fundamentals NEW

Developing Applications with Business Intelligence Beans and Oracle9i JDeveloper: Our Experience. IOUG 2003 Paper 406

SANS Institute Product Review: Oracle Database Vault

Oracle JDeveloper/Oracle ADF 11g Production Project Experience

Oracle Database: Program with PL/SQL Ed 2

Using SQL Developer. Oracle University and Egabi Solutions use only

Oracle Database 12c R2: Program with PL/SQL Ed 2 Duration: 5 Days

Conditionally control code flow (loops, control structures). Create stored procedures and functions.

Real Application Security Administration

Hello Worldwide Web: Your First JSF in JDeveloper

Learn Well Technocraft

Oracle Database 12c: Program with PL/SQL Duration: 5 Days Method: Instructor-Led

Oracle Database 11g: SQL and PL/SQL Fundamentals

Database Programming with SQL

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Exploring Best Practices and Guidelines for Tuning SQL Statements

ORACLE PL/SQL DATABASE COURSE

Bsc (Hons) Software Engineering. Examinations for / Semester 1. Resit Examinations for BSE/15A/FT & BSE/16A/FT

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database: SQL Fundamentals I. Q&As: 292

Security Benefits of Implementing Database Vault. -Arpita Ghatak

ITCertMaster. Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way!

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

using PL/SQL and APEX

Certification Exam Preparation Seminar: Oracle Database SQL

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database 11g: Program with PL/ SQL. Version: Demo

EXTENDING YOUR HCM CLOUD SELF SERVICE IS AS SIMPLE AS

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Fusion Middleware 11g: Build Applications with Oracle Forms

ORACLE DATABASE 12C INTRODUCTION

Oracle - Oracle Database: Program with PL/SQL Ed 2

Dynamic Database Schemas and Multi-Paradigm Persistence Transformations

New Oracle 12c Features for Developers

to-end Solution Using OWB and JDeveloper to Analyze Your Data Warehouse

BraindumpsVCE. Best vce braindumps-exam vce pdf free download

Database Programming with PL/SQL

Do-It-Yourself Data Migration

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Database. Installation and Configuration of Real Application Security Administration (RASADM) Prerequisites

BEST PRACTICES FOR DEVELOPING GEOSPATIAL BIG DATA APPS FOR THE CLOUD. Nick Salem - Distinguished Engineer David Tatar - Principal Software Engineer

ORACLE APPLICATION EXPRESS, ORACLE REST DATA SERVICES, & WEBLOGIC 12C AUTHOR: BRAD GIBSON SENIOR SOLUTIONS ARCHITECT ADVIZEX

Just Get It Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console Hands on Practice

Introduction to ADF Core Technologies

Introduction. Introduction to Oracle: SQL and PL/SQL

<Insert Picture Here> Edition-based redefinition: the key to online application upgrade

MySQL for Database Administrators Ed 4

5/31/18 AGENDA AIS OVERVIEW APPLICATION INTERFACE SERVICES. REST and JSON Example AIS EXPLAINED. Using AIS you can perform actions such as:

Oracle Database: SQL and PL/SQL Fundamentals

<Insert Picture Here> Oracle SQL Developer: PL/SQL Support and Unit Testing

1. Data Model, Categories, Schemas and Instances. Outline

ORACLE VIEWS ORACLE VIEWS. Techgoeasy.com

ADF Code Corner How-to restrict the list of values retrieved by a model driven LOV. Abstract: twitter.com/adfcodecorner

Database Programming with SQL

DB Fundamentals Exam.

Data Manipulation Language

Manipulating Data. Copyright 2004, Oracle. All rights reserved.

Introduction to Computer Science

Database Programming - Section 18. Instructor Guide

Vendor: Oracle. Exam Code: 1Z Exam Name: MySQL 5.0, 5.1 and 5.5 Certified Associate Exam. Version: Demo

Oracle Application Development Framework Overview

Made from the Same Mold: Templating Approaches for ADF Faces Applications

Transcription:

Using Thick Database Principles to Leverage Oracle SQL and PL/SQL Part III: Implementation Techniques Peter Koletzke Technical Director & Principal Instructor Me 34 yrs. database industry 30 yrs. consulting in Oracle arena Since Oracle 5.1C, SQL*Forms 2.3 38 yrs. as trainer/presenter User groups 350+ presentations, 12 awards 7+ yrs. total on boards of directors IOUG(-A), NYOUG, UTOUG Oracle ACE Director Since program inception in Aug. 2005 Oracle Certified Master Since program inception in Dec. 2001 8 Oracle Press books coauthored 6262 pages total Designer/2000 Handbook JDeveloper 3 Handbook Designer Handbook, Second Edition ORACLE9i JDeveloper Handbook Developer Advanced Forms & Reports ORACLE JDeveloper 10g Handbook

You Job responsibilities? DBA, developer Development tools? Oracle Developer Forms/Reports APEX ADF, MAF MAX, VBCS Other JavaScript tools.net PL/SQL Other 3 Series Overview Earlier sessions Thick Concepts Business Rules What is Thick Database? Why is Thick faster? Thick Advice The subject is business rules Sample business rules systems Where to place business rules code Techniques Thick Database objects Sample code Level of Thick Slides will be available on the NoCOUG website. 4

A Brief Review About Thick Database A code development strategy Maximize use of database code to simplify the user interface The user s device (client) runs minimal code Name plays off the term thin client A Year of the Internet term Means most processing occurs on a server Slightly outmoded now Thick database means thin client A.k.a. Thick Database Approach Thick Database Paradigm Smart Database SmartDB Fat Database Oracle prefers 6

Guiding Principles for Code Database code that implements business rules in PL/SQL Using database features to enforce data integrity defined by business rules seems obvious Database views to represent complex business objects (SQL) Each view has an accompanying application programming interface (API) Written in PL/SQL Interaction is with view and API 7 Benefits Application accuracy Business rules match application code Test plans can be generated from business rules system Productivity Can greatly simplify user interface code Code reusability Ease of application maintenance Faster performance Code is close to data storage fewer messages, easy access Views also reduce the number of round trips needed Proper use of staff User interface developers can concentrate on UI code Database code developers can concentrate on database code to support the UI 8

More Benefits Save cloud database processing time Application s use of database is more efficient Proof in next section Less database processing time == lower cloud costs Save application processing time, too Simplify user interface development Database views and PL/SQL form API to the database Application code is reduced UI code technology can change without total application rewrite 9 Two Related Strategies 1. System for tracking business rules Store definitions in database tables Code implementations linked to rules Linked to, or serves as, requirements documentation 2. Database features implement the business rules Constraints Database API: PL/SQL code, updatable views Oracle is considering support for SQL Assertions: https://community.oracle.com/ideas/13028 10

Agenda Thick Database objects Thick Techniques Sample code Level of Thick 11 Yogi Berra The towels were so thick there I could barely close my suitcase.

How Many Schemas? Two Connect schema Table owner schema (owns PL/SQL code and tables) OR Three Connect schema PL/SQL schema (bus rules and TAPI code; views) (AUTHID DEFINER) Table owner schema (owns tables) OR Four (1) Connect schema API PL/SQL schema (owns API code; views; package per page) BR PL/SQL schema (owns bus rules code) Table owner schema (owns tables) Synonyms - optional DDL triggers to guard against additional grants or disabling triggers or creating synonyms (1) Why Use PL/SQL? By Bryn Llewellyn 13 Tables the usual Database Components No grants or synonyms to other schemas Table API packages INSERT, UPDATE, DELETE, (SELECT) procedures Call business rules validation code Views on the tables Queries can be arbitrarily complex INSTEAD OF triggers on the views Call the table API procedures 14

Agenda Thick Database objects Thick Techniques Sample code Level of Thick 15 Table API A PL/SQL package per table All data modification ( DML ) is accomplished through procedures INS() UPD() DEL() LCK() Procedures are called only from INSTEAD OF view triggers No grants to table at all Code samples are available in Appendix A. Demo 1 16

Optional Table API Components A function can act as SELECT A bit trickier and not always necessary Virtual Private Database policies can filter data to all SELECT statements instead Package enforcement global variable Trigger uses it to prevent DML statements outside of the package Applies only to table owner because table has no grants Access only by Table API 17 Package Enforcement Global Variable CREATE OR REPLACE TRIGGER employees_trbr BEFORE INSERT OR UPDATE OR DELETE ON employees FOR EACH ROW BEGIN -- IF NOT employees_pkg.g_allow_dml THEN RAISE_APPLICATION_ERROR(-20199, 'You may not issue INSERT, UPDATE, or ' 'DELETE statements to this table.'); END IF; -- other code for validating rules END employees_trbr; 18

Database Views and Triggers Views on tables requiring access INSTEAD OF triggers on the views INSERT, UPDATE, DELETE row-level trigger Call Table API procedures Exceptions Cross-row validation requires statement-level triggers on tables or application code Cross-table validation requires application code Demo 2 19 SQL Flow Database DML DML INSTEAD OF Trigger View 1 Table 1 API Table 1 Trigger Table 1 Table 2 API Table 3 API Table 3 Trigger Table 3 Table 2 Trigger Table 2 20

Generate the Stub Code It s all cookie cutter stuff at the start Table API triggers and packages View INSTEAD OF trigger Use a prebuilt generator http://www.dbartisans.com/oracle/docs/plsql_frameworks_ and_libraries.pdf https://www.oddgen.org/ André Borngräber, Ottmar Gobrecht https://github.com/oramuc/table-api-generator Or roll your own generator 21 SQL*Developer Solution Select table From right-click menu: Table Generate Table API Be sure to Ctrl-F7 to reformat it You may want to use it just as a basis for your own code 22

NEW! Quick SQL quicksql.oracle.com An APEX app Youtube video published Feb. 2017 Generates code for tables, views, constraints, etc. (even sample data!) based on shorthand specs Settings control variations Table API is one of the options 23 Demo 3 24

A Gotcha: Cross-row Rules Row-level triggers can only check a single record Master-detail form One commit for changes to multiple records Update could be to master or detail(s) or both records Validation must occur between master and all details Also: between rows of the same table Row-level actions will not work In general: need to check business rules after all insert, update, delete statements and before commit Database does not offer a commit trigger 25 Example Department entity object StartDate and EndDate define active period Employees entity object Includes all employees hired or retired StartDate and EndDate define active period Business rules 1. Only one employee can be active in a particular job at a time 2. The active period for an employee must fall within the active period for the department. 26

Employee ID Sample Scenarios Departments DepartmentId 90 DepartmentName Executive StartDate 6/16/2003 EndDate Employees LastName StartDate EndDate JobId Department ID 100 King 6/17/2003 AD_PRES 90 101 Kochhar 9/21/2005 1/12/2007 AD_VP 90 102 DeHaan 1/13/2007 AD_VP 90 Change DeHaan StartDate to 1/1/2007 and commit Change Dept 90 StartDate to 6/18/2003 and commit 27 Cross-row Validation Solution Call cross-table procedure from the UI code before after other updates, before commit Uses current session and can query uncommitted data Query (or pass to procedure) master values and detail records Process the values Return success or failure 28

Other Gotchas Can t use a RETURNING clause for an INSERT on a view with an INSTEAD OF trigger Views cannot have a ROWID column 29 Real World Code Examples Table APIs BR_RULE_PKG BR_RULE_TRBR Database views BR_RULE_VW INSTEAD OF triggers BR_RULE_VW_TRBR Business rules procedures BR_RULE_PKG.VALIDATE_BRRULE_ID() Demo 4 30

Agenda Thick Database objects Thick Techniques Sample code Level of Thick 31 Main Levels Complexity, Flexibility Light Moderate Deep Extreme 32

Light: Application Code Only The simplest architecture Not really Thick Database Business rule statements in printed documents only No link between business rules statements and programming code Difficult to maintain and report on business rules statements Most business rules code in the application Use database constraints 33 Moderate: Application Code with Business Rules Repository Modified Thick Database Approach Business rules statements are stored in database tables: a business rules repository Maintenance and reporting of business rules is easier and more flexible Can report on groups of business rules Names of programmatic objects can be stored in the repository ID numbers for business rules can be added to comments in the application code Link requirements and test plans to business rules 34

Deep: Code Generation Engine Extremely Thick Database Approach Business rules repository as in Moderate Independent of Table API, trigger, etc. stub generators The system generates application code (database and user interface) from the business rules repository Business rules statements are tightly coupled to application code Downside: time consuming to produce an engine that can handle all possibilities Possible compromise: settle for less than 100% generation For example, hand-code the UI application and generate the validation code 35 Benefits of Deep The code is immediately useable (100% generation) Development time is minimized Time spent on proper definitions of business rules Same for maintenance and enhancements A single engine can serve multiple applications Relatively immune to technology shifts Except the UI generator would need to be altered for a different UI technology 36

Extreme: Business Rules Runtime Engine Generic code reads the business rules repository at runtime Generates the user interface dynamically Data are validated using the business rules repository definitions The tightest coupling between application and business rules Development process consists only of defining the business rules Maintenance and enhancements are simple Downside: even more time consuming to produce this system Needs experts to create and maintain Relatively immune to technology shifts Although the runtime engine would need to be altered for a different UI technology 37 Summary Leverage SQL: Database views, no grants to tables Leverage PL/SQL: View INSTEAD OF triggers, table triggers, table APIs Different levels of thick depending on available time and talent Incorporating it requires some ramp-up time: use a phased approach 38

Designer Handbook Developer Advanced Forms & Reports JDeveloper 3 Handbook ORACLE9i JDeveloper Handbook ORACLE JDeveloper 10g Handbook Please fill out the evaluations 7 of 8 books co-authored with Dr. Paul Dorsey, Avrom Roy-Faderman, & Duncan Mills Slides will be on the NoCOUG website 39