Best Practices For PL/SQL Development in Oracle Application Express



Similar documents
Best Practices for Dynamic SQL

6b Continuing Past Exceptions

Making the Most of Oracle PL/SQL Error Management Features

J j enterpririse. Oracle Application Express 3. Develop Native Oracle database-centric web applications quickly and easily with Oracle APEX

Automated Testing Options for PL/SQL Steven Feuerstein PL/SQL Evangelist, Quest Software

ORACLE APPLICATION EXPRESS 5.0

Relational Databases for the Business Analyst

Bullet Proof Your PL/SQL


APEX 4.2 Application Deployment and Application Management. Denes Kubicek

Implementing Database Development Best Practices for Oracle

<Insert Picture Here> Oracle Application Express 4.0

Oracle PL/SQL Best Practices

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: Develop PL/SQL Program Units

SharePoint Checklist and Resources

OPP ODTUG Kaleidoscope. An ODTUG SP* Oracle PL/SQL Programming Conference. WOW-Wide Open World, Wide Open Web!

Error Management in Oracle PL/SQL

<Insert Picture Here> Michael Hichwa VP Database Development Tools Stuttgart September 18, 2007 Hamburg September 20, 2007

How To Develop A Mobile App With Phonegap

Webucator Free Online Technology Training Courses

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database 10g: Introduction to SQL

Search help. More on Office.com: images templates

MyMathLab / MyStatLab Advanced Interactive Training Guide

Oracle Database: SQL and PL/SQL Fundamentals

V-Requester Add-in for Microsoft Outlook

Top Navigation menu - Tabs. User Guide 1. &

Oracle Database 10g: Program with PL/SQL

Canonical. Plugin for Joomla! This manual documents version 3.11.x of the Joomla! extension.

MASTERTAG DEVELOPER GUIDE

General principles and architecture of Adlib and Adlib API. Petra Otten Manager Customer Support

AWS Service Catalog. User Guide

-Android 2.3 is the most used version of Android on the market today with almost 60% of all Android devices running 2.3 Gingerbread -Winner of

INTRODUCING ORACLE APPLICATION EXPRESS. Keywords: database, Oracle, web application, forms, reports

Installation & User Guide

Rapid Application Development of Oracle Web Systems

Track and Keynote/Session Title 9:00:00 AM Keynote 11g Database Development Java Track Database Apex Track.Net Track. 09:30:00 AM with Oracle and

Installation & User Guide

Power Tools for Pivotal Tracker

Oracle Application Express Workshop

Top 10 Oracle SQL Developer Tips and Tricks

Tivoli Endpoint Manager BigFix Dashboard

The Learn-Verified Full Stack Web Development Program

Wie komplex können APEX Applikationen denn werden?

Intellicyber s Enterprise Integration and Application Tools

Google Product. Google Module 1

Web Applications Security: SQL Injection Attack

ANDROID APP DEVELOPMENT: AN INTRODUCTION CSCI /19/14 HANNAH MILLER

Oracle Database: SQL and PL/SQL Fundamentals NEW

Using your content management system EXPRESSIONENGINE CMS DOCUMENTATION UKONS

Lecture 4 Cross-Platform Development. <lecturer, date>

Mobile Development Frameworks Overview. Understand the pros and cons of using different mobile development frameworks for mobile projects.

Communities. Best Practices Implementing Salesforce.com Communities. ForceBrain.com

Mail Chimp Basics. Glossary

Optimizing WordPress Performance: Page Speed and Load Times. Doug Yuen

A Guide To Evaluating a Bug Tracking System

ANDROID APPS DEVELOPMENT FOR MOBILE GAME

Set Up and Maintain Customer Support Tools

How to Use Oracle Account Generator for Project-Related Transactions

Web Programming Languages Overview

MicroStrategy Course Catalog

DIPLOMA IN WEBDEVELOPMENT

Getting Started Developing JavaScript Web Apps. this = that. VT Geospatial Forum 2015

What s new in TIBCO Spotfire 6.5

How To Understand The Error Codes On A Crystal Reports Print Engine

An Introduction to PL/SQL. Mehdi Azarmi

Creating a Restaurant Website

Welcome to the Force.com Developer Day

Build a Mobile App in 60 Minutes with MAF

Designing for the Mobile Web Lesson 3: HTML5 Web Apps

Category: Business Process and Integration Solution for Small Business and the Enterprise

Advanced Workflow Concepts Using SharePoint Designer 2010

Expanded contents. Section 1. Chapter 2. The essence off ASP.NET web programming. An introduction to ASP.NET web programming

Xcelsius Dashboards on SAP NetWaver BW Implementation Best Practices

HTML5. Turn this page to see Quick Guide of CTTC

How to Quickly Create Custom Applications in SharePoint 2010 or 2013 without Custom Code

Silect Software s MP Author

ORACLE 9I / 10G / 11G / PL/SQL COURSE CONTENT

Developing Solutions for Microsoft Dynamics AX in a Shared AOS Development Environment

Lesson Planner. Lesson Planner from Pearson provides an online tool that makes planning lessons easier and allows teachers to adjust lesson plans.

Web Apps: Using web apps to build amazing functionality without programming. I Love Web Apps. They re Awesome.

NewsletterAdmin 2.4 Setup Manual

Migrating Non-Oracle Databases and their Applications to Oracle Database 12c O R A C L E W H I T E P A P E R D E C E M B E R

Change Management for Rational DOORS User s Guide

Introduction to Tizen SDK Alpha. Taiho Choi Samsung Electronics

... Introduction Acknowledgments... 19

Duration Vendor Audience 5 Days Oracle Developers, Technical Consultants, Database Administrators and System Analysts

How To Use Titanium Studio

An Eclipse Plug-In for Visualizing Java Code Dependencies on Relational Databases

Business Insight Report Authoring Getting Started Guide

Toad for Oracle tips & tricks

Apex Code: The World s First On-Demand Programming Language

Elisabetta Zodeiko 2/25/2012

Transcription:

Oracle PL/SQL and APEX Best Practices For PL/SQL Development in Oracle Application Express Steven Feuerstein steven@stevenfeuerstein.com PL/SQL Evangelist Quest Software

Resources for PL/SQL Developers www.plsqlchallenge.com Daily PL/SQL quiz, weekly SQL, APEX and logic quizzes. Prizes! www.plsqlchannel.com 27+ hours of detailed video training on Oracle PL/SQL www.stevenfeuerstein.com Sign up for monthly PL/SQL newsletter www.toadworld.com/sf Quest Software-sponsored portal for PL/SQL developers; download powerpoints and demo.zip Copyright 2011 Feuerstein and Associates Page 2

Best practices all happen in here: A little obsessive... A little compulsive... Is probably an OK thing for a developer. Copyright 2011 Feuerstein and Associates Page 3

The Big Picture on NOT Best Practices Copyright 2011 Feuerstein and Associates Page 4

PL/SQL and APEX: the best and worst of friends Point and click interface to define your application Way better than writing it all in code, right? One language (PL/SQL) for backend and frontend development. Of course, it sure helps to know Javascript, jquery, HTML, CSS, etc. But how well do APEX and PL/SQL play (together)? Copyright 2011 Feuerstein and Associates Page 5

Some Issues We Face Repetition and hard-coding APEX doesn't make it particularly easy to reuse application elements, especially code. When code is written inside that oh-so-cool UI environment, we tend to pay less attention to it. Irritating interruption from the usual point-and-click. Less than minimal editing capabilities. The custom-written source code in your APEX application will present the biggest challenge in terms of debugging, maintenance, support. Copyright 2011 Feuerstein and Associates Page 6

What's an APEX developer to do? Set clear rules on... Where code goes, and Where and how SQL statements are written. Don't repeat anything hide everything. Soft-code as much as you can. Oracle PL/SQL Programming Fully leverage APEX's close connection to Oracle tables. Prepare for (assume) the worst. Copyright 2011 Feuerstein and Associates Page 7

Set Some Clear Rules 1. If the PL/SQL code does not contain references to UI elements, move to packages. 2. If the PL/SQL code contains UI elements, move as much code as possible to packages. Leave behind a minimal "footprint" in APEX code. 3. The only SQL you should write inside APEX are queries to populate tables. And even then you should query from views. No updates, inserts, deletes - unless generated and performed automatically by APEX. Copyright 2011 Feuerstein and Associates Page 8

Don't repeat anything hide everything. This is Golden Rule of Programming. Repetition = hard coding = maintenance nightmare. You end up with brittle, hard-to-change apps. Instead, aim for a Single Point of Definition (SPOD) for every aspect of your application. That way, when you have to change it, you change it in one place The hard part is recognizing all the sorts of hard-codings that can occur. Copyright 2011 Feuerstein and Associates Page 9

Common Hard Codings in APEX Literals that are defined in PL/SQL as constants, but cannot be referenced in queries. WHERE clauses, validations, conditions Entire pages of similar functionality. Be ruthless and disciplined. Oracle PL/SQL Programming Single, shared pages are more complex, but in the long run easier to maintain. Page 651 Copyright 2011 Feuerstein and Associates Page 10

Hide with PL/SQL Packages Key building block for any PL/SQL-based application. Move as much code as possible into packages, avoid schema-level functions and procedures. Create lots of small, narrowly focused packages. Build a toolbox of handy utilities. Examples from the PL/SQL Challenge code base: Application configuration/constants (qdb_config) URL management (qdb_utilities.apex_url) Date manipulation (qdb_utilities) Template processing (qdb_template_mgr) Practice management (qdb_practice_mgr) Page 651 Lesson Summary How It's Useful Items Copyright 2011 Feuerstein and Associates Page 11

Hide Your SQL We PL/SQL developers take SQL completely for granted. It's so easy to write! But what do we know about SQL statements? They change constantly, forcing us to change code; cause most of the performance problems; cause many runtime errors in an application. Seems to me we should very careful about how, when and where we write SQL statements. Don't take SQL for granted! Copyright 2011 Feuerstein and Associates Page 12

Compile Time vs Run Time One big advantage of putting you SQL in PL/SQL subprograms or even views is that any errors are detected at compile time. If you "dump" the SQL into APEX, then you (or your users) don't see the error until run time. This is especially dangerous with upgrades, and consequent incomplete testing. Step 1: add new columns to table X. Has same name as column in table it joins with. Step 2: upgrade all packages to support new column. All looks OK, but... Problem: getting "ambiguous column" errors in application but only if and when you actually exercise that page. Copyright 2011 Feuerstein and Associates Page 13

In the context of APEX... Your APEX-based, custom-written source code should never contain SQL statements. Except for "simple" queries against views. Replace validation and branch queries with functions. Create or generate table APIs or transaction APIs to hide the SQL. It's always more complicated than it initially appears. Page 596 Option Management Page 651 Get Review Summary Copyright 2011 Feuerstein and Associates Page 14

Prepare for the Worst Bad things will happen on your website. How prepared are you (and your application code) to deal with them? Every well-designed application should have: Execution tracing: enable with "flip of switch" Error logging: make it easy for developers to log and raise errors. Dashboard to easily check status Notifications of problems: email, text, etc. Copyright 2011 Feuerstein and Associates Page 15

What we do at PL/SQL Challenge Application tracing The "usual" for PL/SQL code and also "in-line" trace calls to add to expressions in APEX. Maintain system log for critical information that we don't want lost in the regular trace. Integrated test case definition and results tracking Page 651 Lesson Summary expression Copyright 2011 Feuerstein and Associates Page 16

And Finally Some Little Things Put all PL/SQL code inside BEGIN-END blocks. Then you can copy into Toad (or your IDE) and reformat it, then paste it back. More generally, use your IDE to format all the SQL and PL/SQL statements so you can read it more easily. All application items are strings! Watch out for overloadings of string and number. Watch out for comparisons of "date" items. Page 2024 End date validation Copyright 2011 Feuerstein and Associates Page 17

PL/SQL and APEX: a match made in Oracle It's not surprising that it's easy to work with PL/SQL from within APEX. But as with SQL, just because it's easy doesn't mean you should treat it casually. Write your PL/SQL code with care. Move as much as possible to PL/SQL packages. Decide on clear standards for SQL construction, error management, naming conventions. Build tracing into your code. Test it thoroughly. Copyright 2011 Feuerstein and Associates Page 18