Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Buy Now $31.99
Standard view
Full view
of .
Save to My Library
Look up keyword or section
Like this
2Activity

Table Of Contents

Introduction
About This Book
Foolish Assumptions
How This Book Is Organized
Part I: Basic PL/SQL Concepts
Part II: Getting Started with PL/SQL
Part III: Standards and Structures
Part IV: PL/SQL Data Manipulations
Part V: Taking PL/SQL to the Next Level
Part VI: The Part of Tens
Icons Used in This Book
Where to Go from Here
Chapter 1
Knowing Just Enough about Relational Databases
What makes a database “relational”?
Understanding basic database terminology
Introducing database normalization
What is a DBMS?
The Scoop on SQL and PL/SQL
The purpose of SQL and PL/SQL
The difference between SQL and PL/SQL
What’s new in Oracle SQL and PL/SQL?
What Is PL/SQL Good For?
Using database triggers
Scripting with speed
Keeping code server-side
Programming for Oracle Developer
Setting Up an Oracle Environment
Hardware and Software Requirements
Accessing the Oracle Technology Network
Installing the Database
Working with Code
SQL*Plus
Oracle SQL Developer
Third-party tools
Establishing a Database Connection
Checking the operating services
Connecting with your username
Unlocking (or locking) accounts
Resetting passwords
Setting up the server to communicate
The Basics of PL/SQL Programs
Writing a simple program
Creating stored procedures
Passing parameters to procedures
Examining the Sample Data
The Scott/Tiger schema
The Human Resources (HR) and Order Entry (OE) schemas
ᮣUsing PL/SQL as a programming language
PL/SQL As a Programming Language
Anonymous PL/SQL Blocks
Introducing the Lexical Set of Elements
Identifiers
Delimiters
Literals
Comments
Working with Constants and Variables
Declaring variables
Assigning values to variables
Literals as variable values
Understanding the scope of variables
Building Expressions with Operators
Running Anonymous Blocks of Code
Identifying common mistakes
Spotting compilation errors
Recognizing semicolon-related errors
Creating Reusable PL/SQL Code
Wrapping a task into a procedure
Returning values with functions
Parameters of subprograms
Storing PL/SQL in the Database
Database procedures and functions
Packages
Triggers
Interpreting and fixing compilation errors
Checking Out PL/SQL Extras
Overloading calls
Resolving calls to subprograms
Recursion
Compiler hints and directives
Built-in packages
Creating Condition Statements
IF...THEN statements
IF...ELSE statements
CASE statements
Comparing with NULL
Handling conditions
Looping the Loop
Simple loops
Nested loops
WHILE loop
FOR loop
Understanding Exception Basics
Adding Exception Handlers to Your Code
Understanding Different Exception Types
Predefined Exceptions in PL/SQL Code
Adding User-Defined Exceptions
Assigning a code to a user-defined exception
Including error messages in user-defined exceptions
Propagation of Exceptions
Seeing propagation of exceptions in action
Handling exceptions without halting the program
Writing Exceptional Exceptions
Cursors: What They Are and How to Use Them
Returning more than one piece of information
Looping through multiple records
Placing cursors in nested loops
Passing parameters to cursors
Knowing Where to Declare Cursors
Defining cursors in the header of the program unit
Defining cursors in the local PL/SQL block
Defining cursors in the package body
Defining cursors in the package spec
Being Explicitly Smart with Implicit Cursors
Retrieving a single row: The basic syntax
Handling exceptions in implicit cursors
Returning an implicit cursor into a record
Accessing Status Info by Using Cursor Variables
Checking the status of explicit cursors
Checking the status of implicit cursors
Updating Records Fetched from Cursors
Using a simple UPDATE statement
Updating with logical operators
Taking a Shortcut with CURSOR FOR Loops
When do CURSOR FOR loops simplify exception handling?
When CURSOR FOR loops make your life harder
Knowing what record is processing
Referencing Functions in SQL
Important facts to remember
Getting good performance with functions
ᮣPlacing code in the database
Putting Code in the Database
Managing code
Packaging code in the database
Placing triggers on tables
Building INSTEAD OF trigger views
Advantages of putting code in the database
Disadvantages of putting code in the database
Putting Code in the Application Server (Middle-Tier Approach)
Advantages of the middle-tier approach
Disadvantages of the middle-tier approach
Placing code in the view layer
Where Should You Place the Business Logic?
What’s in a Naming Standard?
Oracle database influences
Java influences
Setting Naming Standards for Common Code Elements
Basic objects
Variables
Program units: Procedures, packages, functions, triggers
Parameters in code objects
Exceptions
User-defined datatypes
Collections
Filenames
Making Sure Your Organization Follows Standards
Why Standards Are Important
Universal Truths
Don’t hard-code any constant value
Don’t make your program units too big or too small
Put each data element on its own line
Using the NUMBER datatype
Boosting performance with BINARY_INTEGER
Handling numeric datatypes in built-in functions
Keeping Track of Date and Time
Selecting the info you want from DATE
Using TIMESTAMP
Using TIMESTAMP WITH TIME ZONE
Storing elapsed time with INTERVAL
Working with dates and built-in functions
Storing Logical Values with BOOLEAN
Processing Characters and Strings
Limiting variable length with CHAR versus VARCHAR2
Useful character built-in functions
Extending your options with regular expressions
Handling Large Objects in the Database
Using internal large objects (CLOB, BLOB)
Creating pointers with external large objects
Working with Large Objects
Populating BFILE
Loading data to the CLOB by using BFILE
Loading a page to a BLOB
Performing basic string operations on CLOBs
Keeping Code Consistent with User-Defined Subtypes
Defining Your Own Datatypes
Records
Object types
Grouping Sets of Data into Collections
Using VARRAYs
Nesting variable data sets in tables
Associative arrays (index-by tables)
Speeding Up Data Collection with Bulk Operations
Using the BULK COLLECT command
Adding a limit to BULK COLLECT
Using Transactions to Maintain Data Consistency
Committing or Rolling Back Changes to the Database
Firing explicit and implicit commits
Rolling back changes
Knowing when to use implicit rollbacks
Resolving deadlocks
Autonomous Transactions
Setting up the syntax for an autonomous transaction
Autonomous transaction features
Taking Advantage of Dynamic SQL
A Simple EXECUTE IMMEDIATE
Improve performance with bind variables
Return information using cursor variables
Building DDL on the Fly
Using Quoted Strings with Dynamic SQL
Working with Advanced Datatypes
Using BULK COLLECT with dynamic SQL
Dynamic OPEN...FOR
Why Are Best Practices Important?
Laying the Groundwork for Good Coding
Understanding the big picture
Communicating effectively
Creating a code specification
Writing Code with Best Practices in Mind
Stub out your code
Check the architecture as you go
Prove code works with test cases
Use code libraries
Keep the code maintainable
Don’t forget about performance
Compile as you go
Debug the timesaving way
Testing Your Code
What are you testing?
Creating a testing architecture
Performance and load testing
Tuning performance
“Good enough is best”
Coding the Agile Way
Working together in Agile teams
Programming in pairs
Delivering code quickly
Test first
Keeping Up-to-Date with Oracle
Conventional wisdom isn’t always right
Buy books
Go to conferences
Join your local Oracle user group
Use online resources
Use SELECT INTO Correctly
Don’t Assume Column Order in DML Statements
Use the NOCOPY Command
Be Careful of Function Calls That Impact Performance
Beware of Implicit Commits
Use Only One RETURN Statement per Function
Save Debugging Time with WHEN OTHERS
Know When to Pass Parameters or Use Global Variables
Use Implicit Cursors When Appropriate
Remember That Dates Are Numbers
Catching an Exception with WHEN OTHERS THEN NULL
Forgetting to Handle NULL Values
Creating Unintended Boolean Expressions
Forgetting to Close an Explicit Cursor
Starting Endless Loops
Reinventing the Wheel
Ignoring Code Readability
Assuming Code Doesn’t Need Comments
Index
P. 1
Oracle PL / SQL For Dummies

Oracle PL / SQL For Dummies

Ratings: (0)|Views: 793|Likes:
Published by Wiley
Find tips for creating efficient PL/SQL code

If you know a bit about SQL, this book will make PL/SQL programming painless!

The Oracle has spoken—you need to get up to speed on PL/SQL programming, right? We predict it'll be a breeze with this book! You'll find out about code structures, best practices, and code naming standards, how to use conditions and loops, where to place PL/SQL code in system projects, ways to manipulate data, and more.

Discover how to

Write efficient, easy-to-maintain code Test and debug PL/SQL routines Integrate SQL and PL/SQL Apply PL/SQL best practices Use new features introduced in Oracle 9i and 10g
Find tips for creating efficient PL/SQL code

If you know a bit about SQL, this book will make PL/SQL programming painless!

The Oracle has spoken—you need to get up to speed on PL/SQL programming, right? We predict it'll be a breeze with this book! You'll find out about code structures, best practices, and code naming standards, how to use conditions and loops, where to place PL/SQL code in system projects, ways to manipulate data, and more.

Discover how to

Write efficient, easy-to-maintain code Test and debug PL/SQL routines Integrate SQL and PL/SQL Apply PL/SQL best practices Use new features introduced in Oracle 9i and 10g

More info:

Publish date: Aug 28, 2006
Added to Scribd: May 14, 2013
Copyright:Traditional Copyright: All rights reservedISBN:9780470054130
List Price: $31.99 Buy Now

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
See more
See less

06/16/2014

435

9780470054130

$31.99

USD

You're Reading a Free Preview
Pages 9 to 225 are not shown in this preview.
You're Reading a Free Preview
Pages 241 to 332 are not shown in this preview.
You're Reading a Free Preview
Pages 341 to 404 are not shown in this preview.
You're Reading a Free Preview
Pages 413 to 435 are not shown in this preview.

You're Reading a Free Preview

Download