Oracle PL/SQL Programming, 4th Edition

Book description

For the past ten years, O'Reilly's Oracle PL/SQL Programming has been the bestselling book on PL/SQL, Oracle's powerful procedural language. Packed with examples and helpful recommendations, the book has helped everyone--from novices to experienced developers, and from Oracle Forms developers to database administrators--make the most of PL/SQL.

The fourth edition is a comprehensive update, adding significant new content and extending coverage to include the very latest Oracle version, Oracle Database 10g Release 2. It describes such new features as the PL/SQL optimizing compiler, conditional compilation, compile-time warnings, regular expressions, set operators for nested tables, nonsequential collections in FORALL, the programmer-defined quoting mechanism, the ability to backtrace an exception to a line number, a variety of new built-in packages, and support for IEEE 754 compliant floating-point numbers.

The new edition adds brand-new chapters on security (including encryption, row-level security, fine-grained auditing, and application contexts), file, email, and web I/O (including the built-in packages DBMS_OUTPUT, UTL_FILE, UTL_MAIL, UTL_SMTP, and UTL_HTTP) and globalization and localization.

Co-authored by the world's foremost PL/SQL authority, Steven Feuerstein, this classic reference provides language syntax, best practices, and extensive code, ranging from simple examples to complete applications--making it a must-have on your road to PL/SQL mastery. A companion web site contains many more examples and additional technical content for enhanced learning.

Publisher resources

View/Submit Errata

Table of contents

  1. Oracle PL/SQL Programming, 4th Edition
  2. Dedication
  3. A Note Regarding Supplemental Files
  4. Preface
    1. Objectives of This Book
    2. Structure of This Book
      1. About the Contents
      2. What This Book Does Not Cover
    3. Conventions Used in This Book
    4. Which Platform or Version?
    5. About the Code
    6. Safari Enabled
    7. Comments and Questions
    8. Acknowledgments
  5. I. Programming in PL/SQL
    1. 1. Introduction to PL/SQL
      1. 1.1. What Is PL/SQL?
      2. 1.2. The Origins of PL/SQL
        1. 1.2.1. The Early Years of PL/SQL
        2. 1.2.2. Improved Application Portability
        3. 1.2.3. Improved Execution Authority and Transaction Integrity
        4. 1.2.4. Humble Beginnings, Steady Improvement
        5. 1.2.5. The Significance of Oracle Database 10g PL/SQL
      3. 1.3. So This Is PL/SQL
        1. 1.3.1. Integration with SQL
        2. 1.3.2. Control and Conditional Logic
        3. 1.3.3. When Things Go Wrong
      4. 1.4. About PL/SQL Versions
        1. 1.4.1. Oracle Database 10g New Features
          1. 1.4.1.1. Optimized compiler
          2. 1.4.1.2. Compile-time warnings
          3. 1.4.1.3. Conditional compilation
          4. 1.4.1.4. Support for nonsequential collections in FORALL
          5. 1.4.1.5. Improved datatype support
          6. 1.4.1.6. Backtrace an exception to its line number
          7. 1.4.1.7. Set operators for nested tables
          8. 1.4.1.8. Support for regular expressions
          9. 1.4.1.9. Programmer-defined quoting mechanism
          10. 1.4.1.10. Many new built-in packages
      5. 1.5. Resources for PL/SQL Developers
        1. 1.5.1. The O’Reilly PL/SQL Series
        2. 1.5.2. PL/SQL on the Internet
      6. 1.6. Some Words of Advice
        1. 1.6.1. Don’t Be in Such a Hurry!
        2. 1.6.2. Don’t Be Afraid to Ask for Help
        3. 1.6.3. Take a Creative, Even Radical Approach
    2. 2. Creating and Running PL/SQL Code
      1. 2.1. SQL*Plus
        1. 2.1.1. Starting Up SQL*Plus
        2. 2.1.2. Running a SQL Statement
        3. 2.1.3. Running a PL/SQL Program
        4. 2.1.4. Running a Script
        5. 2.1.5. What Is the “Current Directory?”
        6. 2.1.6. Other SQL*Plus Tasks
          1. 2.1.6.1. Setting your preferences
          2. 2.1.6.2. Saving output to a file
          3. 2.1.6.3. Exiting SQL*Plus
          4. 2.1.6.4. Editing a statement
          5. 2.1.6.5. Loading your own custom environment automatically on startup
        7. 2.1.7. Error Handling in SQL*Plus
        8. 2.1.8. Why You Will Love and Hate SQL*Plus
      2. 2.2. Performing Essential PL/SQL Tasks
        1. 2.2.1. Creating a Stored Program
        2. 2.2.2. Executing a Stored Program
        3. 2.2.3. Showing Stored Programs
        4. 2.2.4. Managing Grants and Synonyms for Stored Programs
        5. 2.2.5. Dropping a Stored Program
        6. 2.2.6. Hiding the Source Code of a Stored Program
      3. 2.3. Calling PL/SQL from Other Languages
        1. 2.3.1. C: Using Oracle’s Precompiler (Pro*C)
        2. 2.3.2. Java: Using JDBC
        3. 2.3.3. Perl: Using Perl DBI and DBD::Oracle
        4. 2.3.4. PHP: Using Oracle Extensions
        5. 2.3.5. PL/SQL Server Pages
        6. 2.3.6. And Where Else?
    3. 3. Language Fundamentals
      1. 3.1. PL/SQL Block Structure
        1. 3.1.1. Anonymous Blocks
        2. 3.1.2. Named Blocks
        3. 3.1.3. Nested Blocks
        4. 3.1.4. Scope
        5. 3.1.5. Visibility
          1. 3.1.5.1. “Visible” identifiers
          2. 3.1.5.2. Qualified identifiers
          3. 3.1.5.3. Qualifying identifier names with module names
          4. 3.1.5.4. Nested programs
      2. 3.2. The PL/SQL Character Set
      3. 3.3. Identifiers
        1. 3.3.1. Reserved Words
          1. 3.3.1.1. Language keywords
          2. 3.3.1.2. Identifiers from STANDARD package
          3. 3.3.1.3. Approaches to avoiding reserved words
        2. 3.3.2. Whitespace and Keywords
      4. 3.4. Literals
        1. 3.4.1. NULLs
        2. 3.4.2. Embedding Single Quotes Inside a Literal String
        3. 3.4.3. Numeric Literals
        4. 3.4.4. Boolean Literals
      5. 3.5. The Semicolon Delimiter
      6. 3.6. Comments
        1. 3.6.1. Single-Line Comment Syntax
        2. 3.6.2. Multiline Comment Syntax
      7. 3.7. The PRAGMA Keyword
      8. 3.8. Labels
  6. II. PL/SQL Program Structure
    1. 4. Conditional and Sequential Control
      1. 4.1. IF Statements
        1. 4.1.1. The IF-THEN Combination
        2. 4.1.2. The IF-THEN-ELSE Combination
        3. 4.1.3. The IF-THEN-ELSIF Combination
        4. 4.1.4. Nested IF Statements
        5. 4.1.5. Short-Circuit Evaluation
      2. 4.2. CASE Statements and Expressions
        1. 4.2.1. Simple CASE Statements
        2. 4.2.2. Searched CASE Statements
        3. 4.2.3. Nested CASE Statements
        4. 4.2.4. CASE Expressions
      3. 4.3. The GOTO Statement
      4. 4.4. The NULL Statement
        1. 4.4.1. Improving Program Readability
        2. 4.4.2. Nullifying a Raised Exception
        3. 4.4.3. Using NULL After a Label
    2. 5. Iterative Processing with Loops
      1. 5.1. Loop Basics
        1. 5.1.1. Examples of Different Loops
        2. 5.1.2. Structure of PL/SQL Loops
      2. 5.2. The Simple Loop
        1. 5.2.1. Terminating a Simple Loop: EXIT and EXIT WHEN
        2. 5.2.2. Emulating a REPEAT UNTIL Loop
        3. 5.2.3. The Intentionally Infinite Loop
      3. 5.3. The WHILE Loop
      4. 5.4. The Numeric FOR Loop
        1. 5.4.1. Rules for Numeric FOR Loops
        2. 5.4.2. Examples of Numeric FOR Loops
        3. 5.4.3. Handling Nontrivial Increments
      5. 5.5. The Cursor FOR Loop
        1. 5.5.1. Example of Cursor FOR Loops
      6. 5.6. Loop Labels
      7. 5.7. Tips for Iterative Processing
        1. 5.7.1. Use Understandable Names for Loop Indexes
        2. 5.7.2. The Proper Way to Say Goodbye
        3. 5.7.3. Obtaining Information About FOR Loop Execution
        4. 5.7.4. SQL Statement as Loop
    3. 6. Exception Handlers
      1. 6.1. Exception-Handling Concepts and Terminology
      2. 6.2. Defining Exceptions
        1. 6.2.1. Declaring Named Exceptions
        2. 6.2.2. Associating Exception Names with Error Codes
          1. 6.2.2.1. Using EXCEPTION_INIT
          2. 6.2.2.2. Recommended uses of EXCEPTION_INIT
        3. 6.2.3. About Named System Exceptions
        4. 6.2.4. Scope of an Exception
      3. 6.3. Raising Exceptions
        1. 6.3.1. The RAISE Statement
        2. 6.3.2. Using RAISE_APPLICATION_ERROR
      4. 6.4. Handling Exceptions
        1. 6.4.1. Built-in Error Functions
          1. 6.4.1.1. More on DBMS_UTILITY.FORMAT_ERROR_BACKTRACE
          2. 6.4.1.2. Just the line number, please
          3. 6.4.1.3. Useful applications of SQLERRM
        2. 6.4.2. Combining Multiple Exceptions in a Single Handler
        3. 6.4.3. Unhandled Exceptions
        4. 6.4.4. Propagation of an Unhandled Exception
          1. 6.4.4.1. Losing exception information
          2. 6.4.4.2. Examples of propagation
        5. 6.4.5. Continuing Past Exceptions
        6. 6.4.6. Writing WHEN OTHERS Handling Code
      5. 6.5. Building an Effective Error Management Architecture
        1. 6.5.1. Decide on Your Error Management Strategy
        2. 6.5.2. Organize Use of Application-Specific Error Codes
        3. 6.5.3. Work with Your Own Exception “Objects”
        4. 6.5.4. Use Standardized Error Management Programs
        5. 6.5.5. Create Standard Templates for Common Error Handling
      6. 6.6. Making the Most of PL/SQL Error Management
  7. III. PL/SQL Program Data
    1. 7. Working with Program Data
      1. 7.1. Naming Your Program Data
      2. 7.2. Overview of PL/SQL Datatypes
        1. 7.2.1. Character Data
        2. 7.2.2. Numbers
        3. 7.2.3. Dates, Timestamps, and Intervals
        4. 7.2.4. Booleans
        5. 7.2.5. Binary Data
        6. 7.2.6. ROWIDs
        7. 7.2.7. REF Cursors
        8. 7.2.8. Internet Datatypes
        9. 7.2.9. “Any” Datatypes
        10. 7.2.10. User-Defined Datatypes
      3. 7.3. Declaring Program Data
        1. 7.3.1. Declaring a Variable
        2. 7.3.2. Declaring Constants
        3. 7.3.3. The NOT NULL Clause
        4. 7.3.4. Anchored Declarations
        5. 7.3.5. Anchoring to Cursors and Tables
        6. 7.3.6. Benefits of Anchored Declarations
          1. 7.3.6.1. Synchronization with database columns
          2. 7.3.6.2. Normalization of local variables
        7. 7.3.7. Anchoring to NOT NULL Datatypes
      4. 7.4. Programmer-Defined Subtypes
      5. 7.5. Conversion Between Datatypes
        1. 7.5.1. Implicit Data Conversion
          1. 7.5.1.1. Limitations of implicit conversion
          2. 7.5.1.2. Drawbacks of implicit conversion
        2. 7.5.2. Explicit Datatype Conversion
          1. 7.5.2.1. The CHARTOROWID function
          2. 7.5.2.2. The CAST function
          3. 7.5.2.3. The CONVERT function
          4. 7.5.2.4. The HEXTORAW function
          5. 7.5.2.5. The RAWTOHEX function
          6. 7.5.2.6. The ROWIDTOCHAR function
    2. 8. Strings
      1. 8.1. String Datatypes
        1. 8.1.1. The VARCHAR2 Datatype
        2. 8.1.2. The CHAR Datatype
        3. 8.1.3. String Subtypes
      2. 8.2. Working with Strings
        1. 8.2.1. Specifying String Constants
        2. 8.2.2. Using Nonprintable Characters
        3. 8.2.3. Concatenating Strings
        4. 8.2.4. Dealing with Case
          1. 8.2.4.1. Forcing a string to all upper- or lowercase
          2. 8.2.4.2. Making comparisons case-insensitive
          3. 8.2.4.3. Capitalizing each word in a string
        5. 8.2.5. Traditional Searching, Extracting, and Replacing
        6. 8.2.6. Padding
        7. 8.2.7. Trimming
        8. 8.2.8. Regular Expression Searching, Extracting, and Replacing
          1. 8.2.8.1. Detecting a pattern
          2. 8.2.8.2. Locating a pattern
          3. 8.2.8.3. Extracting text matching a pattern
          4. 8.2.8.4. Replacing text (it’s magic!)
          5. 8.2.8.5. Groking greediness
          6. 8.2.8.6. Learning more about regular expressions
        9. 8.2.9. Working with Empty Strings
        10. 8.2.10. Mixing CHAR and VARCHAR2 Values
          1. 8.2.10.1. Database-to-variable conversion
          2. 8.2.10.2. Variable-to-database conversion
          3. 8.2.10.3. String comparisons
          4. 8.2.10.4. Character functions and CHAR arguments
      3. 8.3. String Function Quick Reference
    3. 9. Numbers
      1. 9.1. Numeric Datatypes
        1. 9.1.1. The NUMBER Type
        2. 9.1.2. The PLS_INTEGER Type
        3. 9.1.3. The BINARY_INTEGER Type
        4. 9.1.4. The BINARY_FLOAT and BINARY_DOUBLE Types
        5. 9.1.5. Numeric Subtypes
      2. 9.2. Number Conversions
        1. 9.2.1. The TO_NUMBER Function
          1. 9.2.1.1. Using TO_NUMBER with no format
          2. 9.2.1.2. Using TO_NUMBER with a format model
          3. 9.2.1.3. Passing NLS settings to TO_NUMBER
        2. 9.2.2. The TO_CHAR Function
          1. 9.2.2.1. Using TO_CHAR with no format
          2. 9.2.2.2. Using TO_CHAR with a format model
          3. 9.2.2.3. The V format element
          4. 9.2.2.4. Rounding when converting numbers to character strings
          5. 9.2.2.5. Dealing with spaces when converting numbers to character strings
          6. 9.2.2.6. Passing NLS settings to TO_CHAR
        3. 9.2.3. Using CAST
        4. 9.2.4. Implicit Conversions
      3. 9.3. Numeric Functions
        1. 9.3.1. Rounding and Truncation Functions
        2. 9.3.2. Trigonometric Functions
        3. 9.3.3. Numeric Function Quick Reference
    4. 10. Dates and Timestamps
      1. 10.1. Datetime Datatypes
        1. 10.1.1. Declaring Datetime Variables
        2. 10.1.2. Choosing a Datetime Datatype
      2. 10.2. Getting the Date and Time
      3. 10.3. Interval Datatypes
        1. 10.3.1. Declaring INTERVAL Variables
        2. 10.3.2. When to Use INTERVALs
          1. 10.3.2.1. Finding the difference between two datetime values
          2. 10.3.2.2. Designating periods of time
      4. 10.4. Datetime Conversions
        1. 10.4.1. From Strings to Datetimes
        2. 10.4.2. From Datetimes to Strings
        3. 10.4.3. Working with Time Zones
        4. 10.4.4. Requiring a Format Mask to Match Exactly
        5. 10.4.5. Easing Up on Exact Matches
        6. 10.4.6. Interpreting Two-Digit Years in a Sliding Window
        7. 10.4.7. Converting Time Zones to Character Strings
        8. 10.4.8. Padding Output with Fill Mode
      5. 10.5. Date and Timestamp Literals
      6. 10.6. Interval Conversions
        1. 10.6.1. Going from Numbers to Intervals
        2. 10.6.2. Converting Strings to Intervals
        3. 10.6.3. Formatting Intervals for Display
      7. 10.7. Interval Literals
      8. 10.8. CAST and EXTRACT
        1. 10.8.1. The CAST Function
        2. 10.8.2. The EXTRACT Function
      9. 10.9. Datetime Arithmetic
        1. 10.9.1. Adding and Subtracting Intervals to/from Datetimes
        2. 10.9.2. Computing the Interval Between Two Datetimes
        3. 10.9.3. Mixing DATEs and TIMESTAMPs
        4. 10.9.4. Adding and Subtracting Intervals
        5. 10.9.5. Multiplying and Dividing Intervals
        6. 10.9.6. Using Unconstrained INTERVAL Types
      10. 10.10. Date/Time Functions
    5. 11. Records
      1. 11.1. Records in PL/SQL
        1. 11.1.1. Benefits of Using Records
          1. 11.1.1.1. Data abstraction
          2. 11.1.1.2. Aggregate operations
          3. 11.1.1.3. Leaner, cleaner code
        2. 11.1.2. Declaring Records
        3. 11.1.3. Programmer-Defined Records
          1. 11.1.3.1. Declaring programmer-defined record TYPEs
          2. 11.1.3.2. Declaring the record
          3. 11.1.3.3. Examples of programmer-defined record declarations
        4. 11.1.4. Working with Records
          1. 11.1.4.1. Record-level operations
          2. 11.1.4.2. Field-level operations
          3. 11.1.4.3. Field-level operations with nested records
          4. 11.1.4.4. Field-level operations with package-based records
        5. 11.1.5. Comparing Records
        6. 11.1.6. Trigger Pseudo-Records
    6. 12. Collections
      1. 12.1. Collections Overview
        1. 12.1.1. Types of Collections
        2. 12.1.2. Collections Concepts and Terminology
        3. 12.1.3. Collection Examples
          1. 12.1.3.1. Using an associative array
          2. 12.1.3.2. Using a nested table
          3. 12.1.3.3. Using a VARRAY
        4. 12.1.4. Where You Can Use Collections
          1. 12.1.4.1. Collections as components of a record
          2. 12.1.4.2. Collections as program parameters
          3. 12.1.4.3. Collections as datatypes of a function’s return value
          4. 12.1.4.4. Collection as “columns” in a database table
          5. 12.1.4.5. Collections as attributes of an object type
        5. 12.1.5. Choosing a Collection Type
      2. 12.2. Collection Methods (Built-Ins)
        1. 12.2.1. The COUNT Method
          1. 12.2.1.1. Boundary considerations
          2. 12.2.1.2. Exceptions possible
        2. 12.2.2. The DELETE Method
          1. 12.2.2.1. Boundary considerations
          2. 12.2.2.2. Exceptions possible
        3. 12.2.3. The EXISTS Method
          1. 12.2.3.1. Boundary considerations
          2. 12.2.3.2. Exceptions possible
        4. 12.2.4. The EXTEND Method
          1. 12.2.4.1. Boundary considerations
          2. 12.2.4.2. Exceptions possible
        5. 12.2.5. The FIRST and LAST Methods
          1. 12.2.5.1. Boundary considerations
          2. 12.2.5.2. Exceptions possible
        6. 12.2.6. The LIMIT Method
          1. 12.2.6.1. Boundary considerations
          2. 12.2.6.2. Exceptions possible
        7. 12.2.7. The PRIOR and NEXT Methods
          1. 12.2.7.1. Boundary considerations
          2. 12.2.7.2. Exceptions possible
        8. 12.2.8. The TRIM Method
          1. 12.2.8.1. Boundary considerations
          2. 12.2.8.2. Exceptions possible
      3. 12.3. Working with Collections
        1. 12.3.1. Declaring Collection Types
          1. 12.3.1.1. Declaring an associative array collection type
          2. 12.3.1.2. Declaring a nested table or VARRAY
          3. 12.3.1.3. Changing nested table of VARRAY characteristics
        2. 12.3.2. Declaring and Initializing Collection Variables
          1. 12.3.2.1. Initializing implicitly during direct assignment
          2. 12.3.2.2. Initializing implicitly via FETCH
          3. 12.3.2.3. VARRAY integration
        3. 12.3.3. Populating Collections with Data
          1. 12.3.3.1. Using the assignment operator
          2. 12.3.3.2. What row values can I use?
          3. 12.3.3.3. Aggregate assignments
          4. 12.3.3.4. Assigning rows from a relational table
          5. 12.3.3.5. Advantage of nonsequential population of collection
        4. 12.3.4. Accessing Data Inside a Collection
        5. 12.3.5. Collections of Complex Datatypes
          1. 12.3.5.1. Collections of records
          2. 12.3.5.2. Collections of objects and other complex types
          3. 12.3.5.3. Multilevel collections
          4. 12.3.5.4. Unnamed nested collections: multidimensional arrays
          5. 12.3.5.5. Basic operations
          6. 12.3.5.6. How deeply can I nest collections?
        6. 12.3.6. Using String-Indexed Collections
        7. 12.3.7. Working with Collections in SQL
          1. 12.3.7.1. The CAST pseudo-function
          2. 12.3.7.2. The MULTISET pseudo-function
          3. 12.3.7.3. The TABLE pseudo-function
          4. 12.3.7.4. Sorting contents of collections
      4. 12.4. Nested Table Multiset Operations
        1. 12.4.1. Testing Equality and Membership of Nested Tables
        2. 12.4.2. Checking for Membership of an Element in a Nested Table
        3. 12.4.3. Performing High-Level Set Operations
        4. 12.4.4. Handling Duplicates in a Nested Table
      5. 12.5. Maintaining Schema-Level Collections
        1. 12.5.1. Necessary Privileges
        2. 12.5.2. Collections and the Data Dictionary
    7. 13. Miscellaneous Datatypes
      1. 13.1. The BOOLEAN Datatype
      2. 13.2. The RAW Datatype
      3. 13.3. The UROWID and ROWID Datatypes
        1. 13.3.1. Getting at Rowids
        2. 13.3.2. Using Rowids
          1. 13.3.2.1. Do rowids ever change?
          2. 13.3.2.2. Using rowids in Oracle Forms
          3. 13.3.2.3. Using rowids in a cursor FOR loop
          4. 13.3.2.4. Is the use of rowids worth the effort?
      4. 13.4. The LOB Datatypes
      5. 13.5. Working with LOBs
        1. 13.5.1. Understanding LOB Locators
        2. 13.5.2. Empty Versus NULL LOBs
        3. 13.5.3. Creating a LOB
        4. 13.5.4. Writing into a LOB
        5. 13.5.5. Reading from a LOB
        6. 13.5.6. BFILEs Are Different
          1. 13.5.6.1. Creating a BFILE locator
          2. 13.5.6.2. Accessing BFILEs
          3. 13.5.6.3. Using BFILEs to load LOB columns
        7. 13.5.7. Temporary LOBs
          1. 13.5.7.1. Creating a temporary LOB
          2. 13.5.7.2. Freeing a temporary LOB
          3. 13.5.7.3. Checking to see whether a LOB is temporary
          4. 13.5.7.4. Managing temporary LOBs
        8. 13.5.8. Native LOB Operations
          1. 13.5.8.1. SQL semantics may yield temporary LOBs
          2. 13.5.8.2. Performance impact of using SQL semantics
        9. 13.5.9. LOB Conversion Functions
      6. 13.6. Predefined Object Types
        1. 13.6.1. The XMLType Type
        2. 13.6.2. The URI Types
        3. 13.6.3. The Any Types
  8. IV. SQL in PL/SQL
    1. 14. DML and Transaction Management
      1. 14.1. DML in PL/SQL
        1. 14.1.1. A Quick Introduction to DML
          1. 14.1.1.1. The INSERT statement
          2. 14.1.1.2. The UPDATE statement
          3. 14.1.1.3. The DELETE statement
        2. 14.1.2. Cursor Attributes for DML Operations
        3. 14.1.3. RETURNING Information from DML Statements
        4. 14.1.4. DML and Exception Handling
        5. 14.1.5. DML and Records
          1. 14.1.5.1. Record-based inserts
          2. 14.1.5.2. Record-based updates
          3. 14.1.5.3. Using records with the RETURNING clause
          4. 14.1.5.4. Restrictions on record-based inserts and updates
      2. 14.2. Bulk DML with the FORALL Statement
        1. 14.2.1. Syntax of the FORALL Statement
        2. 14.2.2. Context-Switching Problem Scenarios
        3. 14.2.3. FORALL Examples
        4. 14.2.4. Cursor Attributes for FORALL
        5. 14.2.5. ROLLBACK Behavior with FORALL
        6. 14.2.6. Continuing Past Exceptions with FORALL
        7. 14.2.7. Driving FORALL with Nonsequential Arrays
          1. 14.2.7.1. INDICES OF example
          2. 14.2.7.2. VALUES OF example
      3. 14.3. Transaction Management
        1. 14.3.1. The COMMIT Statement
        2. 14.3.2. The ROLLBACK Statement
        3. 14.3.3. The SAVEPOINT Statement
        4. 14.3.4. The SET TRANSACTION Statement
        5. 14.3.5. The LOCK TABLE Statement
      4. 14.4. Autonomous Transactions
        1. 14.4.1. Defining Autonomous Transactions
        2. 14.4.2. Rules and Restrictions on Autonomous Transactions
        3. 14.4.3. Transaction Visibility
        4. 14.4.4. When to Use Autonomous Transactions
        5. 14.4.5. Building an Autonomous Logging Mechanism
    2. 15. Data Retrieval
      1. 15.1. Cursor Basics
        1. 15.1.1. Some Data Retrieval Terms
        2. 15.1.2. Typical Query Operations
        3. 15.1.3. Introduction to Cursor Attributes
          1. 15.1.3.1. The %FOUND attribute
          2. 15.1.3.2. The %NOTFOUND attribute
          3. 15.1.3.3. The %ROWCOUNT attribute
          4. 15.1.3.4. The %ISOPEN attribute
          5. 15.1.3.5. The %BULK_ROWCOUNT attribute
          6. 15.1.3.6. The %BULK_EXCEPTIONS attribute
        4. 15.1.4. Referencing PL/SQL Variables in a Cursor
          1. 15.1.4.1. Identifier precedence in a cursor
          2. 15.1.4.2. Using standard naming conventions
        5. 15.1.5. Choosing Between Explicit and Implicit Cursors
      2. 15.2. Working with Implicit Cursors
        1. 15.2.1. Implicit Cursor Examples
        2. 15.2.2. Error Handling with Implicit Cursors
        3. 15.2.3. Implicit SQL Cursor Attributes
      3. 15.3. Working with Explicit Cursors
        1. 15.3.1. Declaring Explicit Cursors
          1. 15.3.1.1. Naming your cursor
          2. 15.3.1.2. Declaring cursors in packages
        2. 15.3.2. Opening Explicit Cursors
        3. 15.3.3. Fetching from Explicit Cursors
          1. 15.3.3.1. Examples of explicit cursors
          2. 15.3.3.2. Fetching past the last row
        4. 15.3.4. Column Aliases in Explicit Cursors
        5. 15.3.5. Closing Explicit Cursors
        6. 15.3.6. Explicit Cursor Attributes
        7. 15.3.7. Cursor Parameters
          1. 15.3.7.1. Generalizing cursors with parameters
          2. 15.3.7.2. Opening cursors with parameters
          3. 15.3.7.3. Scope of cursor parameters
          4. 15.3.7.4. Cursor parameter modes
          5. 15.3.7.5. Default values for parameters
      4. 15.4. BULK COLLECT
        1. 15.4.1. Limiting Rows Retrieved with BULK COLLECT
        2. 15.4.2. Bulk Fetching of Multiple Columns
        3. 15.4.3. Using the RETURNING Clause with Bulk Operations
      5. 15.5. SELECT ... FOR UPDATE
        1. 15.5.1. Releasing Locks with COMMIT
        2. 15.5.2. The WHERE CURRENT OF Clause
      6. 15.6. Cursor Variables and REF CURSORs
        1. 15.6.1. Why Cursor Variables?
        2. 15.6.2. Similarities to Static Cursors
        3. 15.6.3. Declaring REF CURSOR Types
        4. 15.6.4. Declaring Cursor Variables
        5. 15.6.5. Opening Cursor Variables
        6. 15.6.6. Fetching from Cursor Variables
          1. 15.6.6.1. Handling the ROWTYPE_MISMATCH exception
        7. 15.6.7. Rules for Cursor Variables
          1. 15.6.7.1. Compile-time rowtype matching rules
          2. 15.6.7.2. Runtime rowtype matching rules
          3. 15.6.7.3. Cursor variable aliases
          4. 15.6.7.4. Scope of cursor object
        8. 15.6.8. Passing Cursor Variables as Arguments
          1. 15.6.8.1. Identifying the REF CURSOR type
          2. 15.6.8.2. Setting the parameter mode
        9. 15.6.9. Cursor Variable Restrictions
      7. 15.7. Cursor Expressions
        1. 15.7.1. Using Cursor Expressions
          1. 15.7.1.1. Retrieve subquery as column
          2. 15.7.1.2. Implement a streaming function with the CURSOR expression
        2. 15.7.2. Restrictions on Cursor Expressions
    3. 16. Dynamic SQL and Dynamic PL/SQL
      1. 16.1. NDS Statements
        1. 16.1.1. The EXECUTE IMMEDIATE Statement
        2. 16.1.2. The OPEN FOR Statement
          1. 16.1.2.1. FETCH into variables or records
          2. 16.1.2.2. The USING clause in OPEN FOR
        3. 16.1.3. About the Four Dynamic SQL Methods
          1. 16.1.3.1. Method 1
          2. 16.1.3.2. Method 2
          3. 16.1.3.3. Method 3
          4. 16.1.3.4. Method 4
      2. 16.2. Binding Variables
        1. 16.2.1. Argument Modes
        2. 16.2.2. Duplicate Placeholders
        3. 16.2.3. Passing NULL Values
      3. 16.3. Working with Objects and Collections
      4. 16.4. Dynamic PL/SQL
        1. 16.4.1. Replace Repetitive Code with Dynamic Block
        2. 16.4.2. Implement Method 4 Dynamic SQL in NDS
      5. 16.5. Recommendations for NDS
        1. 16.5.1. Use Invoker Rights for Shared Programs
        2. 16.5.2. Anticipate and Handle Dynamic Errors
        3. 16.5.3. Use Binding Rather Than Concatenation
        4. 16.5.4. Avoid Code Injection with Binding
      6. 16.6. When to Use DBMS_SQL
        1. 16.6.1. Parse Very Long Strings
        2. 16.6.2. Obtain Information About Query Columns
        3. 16.6.3. Meet Method 4 Dynamic SQL Requirements
          1. 16.6.3.1. The “in table” procedural interface
          2. 16.6.3.2. Steps for intab construction
          3. 16.6.3.3. Constructing the SELECT
          4. 16.6.3.4. Defining the cursor structure
          5. 16.6.3.5. Retrieving and displaying data
        4. 16.6.4. Minimize Parsing of Dynamic Cursors
      7. 16.7. NDS Utility Package
  9. V. PL/SQL Application Construction
    1. 17. Procedures, Functions, and Parameters
      1. 17.1. Modular Code
      2. 17.2. Procedures
        1. 17.2.1. Calling a Procedure
        2. 17.2.2. The Procedure Header
        3. 17.2.3. The Procedure Body
        4. 17.2.4. The END Descriptor
        5. 17.2.5. The RETURN Statement
      3. 17.3. Functions
        1. 17.3.1. Structure of a Function
        2. 17.3.2. The RETURN Datatype
        3. 17.3.3. The END Descriptor
        4. 17.3.4. Calling a Function
        5. 17.3.5. Functions Without Parameters
        6. 17.3.6. The Function Header
        7. 17.3.7. The Function Body
        8. 17.3.8. The RETURN Statement
          1. 17.3.8.1. RETURN any valid expression
          2. 17.3.8.2. Multiple RETURNs
          3. 17.3.8.3. RETURN as last executable statement
      4. 17.4. Parameters
        1. 17.4.1. Defining Parameters
        2. 17.4.2. Actual and Formal Parameters
        3. 17.4.3. Parameter Modes
          1. 17.4.3.1. IN mode
          2. 17.4.3.2. OUT mode
          3. 17.4.3.3. IN OUT mode
        4. 17.4.4. Matching Actual and Formal Parameters in PL/SQL
          1. 17.4.4.1. Positional notation
          2. 17.4.4.2. Named notation
          3. 17.4.4.3. Benefits of named notation
        5. 17.4.5. The NOCOPY Parameter Mode Hint
          1. 17.4.5.1. Restrictions on NOCOPY
          2. 17.4.5.2. Impact of NOCOPY
        6. 17.4.6. Default Values
      5. 17.5. Local Modules
        1. 17.5.1. Benefits of Local Modularization
          1. 17.5.1.1. Reducing code volume
          2. 17.5.1.2. Improving readability
        2. 17.5.2. Scope of Local Modules
        3. 17.5.3. Sprucing Up Your Code with Local Modules
      6. 17.6. Module Overloading
        1. 17.6.1. Benefits of Overloading
          1. 17.6.1.1. Supporting many data combinations
        2. 17.6.2. Restrictions on Overloading
        3. 17.6.3. Overloading with Numeric Types
      7. 17.7. Forward Declarations
      8. 17.8. Advanced Topics
        1. 17.8.1. Calling Your Function Inside SQL
          1. 17.8.1.1. Requirements for calling functions in SQL
          2. 17.8.1.2. Restrictions on user-defined functions in SQL
          3. 17.8.1.3. Read consistency and user-defined functions
          4. 17.8.1.4. Replacing DECODEs with IF statements
          5. 17.8.1.5. The PRAGMA RESTRICT_REFERENCES (Oracle8 Database and earlier)
        2. 17.8.2. Table Functions
          1. 17.8.2.1. Calling a function in a FROM clause
          2. 17.8.2.2. Passing table function results with a cursor variable
          3. 17.8.2.3. Creating a streaming function
          4. 17.8.2.4. Creating a pipelined function
          5. 17.8.2.5. Enabling a function for parallel execution
        3. 17.8.3. Deterministic Functions
      9. 17.9. Go Forth and Modularize!
    2. 18. Packages
      1. 18.1. Why Packages?
        1. 18.1.1. Demonstrating the Power of the Package
        2. 18.1.2. Some Package-Related Concepts
        3. 18.1.3. Diagramming Privacy
      2. 18.2. Rules for Building Packages
        1. 18.2.1. The Package Specification
        2. 18.2.2. The Package Body
        3. 18.2.3. Initializing Packages
          1. 18.2.3.1. Execute complex initialization logic
          2. 18.2.3.2. Cache static session information
          3. 18.2.3.3. Avoid side effects when initializing
          4. 18.2.3.4. When initialization fails
      3. 18.3. Rules for Calling Packaged Elements
      4. 18.4. Working with Package Data
        1. 18.4.1. Global Within a Single Oracle Session
        2. 18.4.2. Global Public Data
        3. 18.4.3. Packaged Cursors
          1. 18.4.3.1. Declaring packaged cursors
          2. 18.4.3.2. Working with packaged cursors
        4. 18.4.4. Serializable Packages
      5. 18.5. When to Use Packages
        1. 18.5.1. Encapsulating Data Manipulation
        2. 18.5.2. Avoid Hardcoding Literals
        3. 18.5.3. Improve Usability of Built-in Features
        4. 18.5.4. Group Together Logically Related Functionality
        5. 18.5.5. Cache Static Session Data
      6. 18.6. Packages and Object Types
    3. 19. Triggers
      1. 19.1. DML Triggers
        1. 19.1.1. DML Trigger Concepts
          1. 19.1.1.1. DML trigger scripts
          2. 19.1.1.2. Transaction participation
        2. 19.1.2. Creating a DML Trigger
          1. 19.1.2.1. The WHEN clause
          2. 19.1.2.2. Working with NEW and OLD pseudo-records
          3. 19.1.2.3. Determining the DML action within a trigger
        3. 19.1.3. DML Trigger Example: No Cheating Allowed!
          1. 19.1.3.1. Applying the WHEN clause
          2. 19.1.3.2. Using pseudo-records to fine-tune trigger execution
        4. 19.1.4. Multiple Triggers of the Same Type
        5. 19.1.5. Mutating Table Errors
      2. 19.2. DDL Triggers
        1. 19.2.1. Creating a DDL Trigger
        2. 19.2.2. Available Events
        3. 19.2.3. Available Attributes
        4. 19.2.4. Working with Events and Attributes
          1. 19.2.4.1. What column did I touch?
          2. 19.2.4.2. Lists returned by attribute functions
        5. 19.2.5. Dropping the Undroppable
        6. 19.2.6. The INSTEAD OF CREATE Trigger
      3. 19.3. Database Event Triggers
        1. 19.3.1. Creating a Database Event Trigger
        2. 19.3.2. The STARTUP Trigger
        3. 19.3.3. The SHUTDOWN Trigger
        4. 19.3.4. The LOGON Trigger
        5. 19.3.5. The LOGOFF Trigger
        6. 19.3.6. The SERVERERROR Trigger
          1. 19.3.6.1. SERVERERROR examples
          2. 19.3.6.2. Central error handler
      4. 19.4. INSTEAD OF Triggers
        1. 19.4.1. Creating an INSTEAD OF Trigger
        2. 19.4.2. The INSTEAD OF INSERT Trigger
        3. 19.4.3. The INSTEAD OF UPDATE Trigger
        4. 19.4.4. The INSTEAD OF DELETE Trigger
        5. 19.4.5. Populating the Tables
        6. 19.4.6. INSTEAD OF Triggers on Nested Tables
      5. 19.5. AFTER SUSPEND Triggers
        1. 19.5.1. Setting Up for the AFTER SUSPEND Trigger
        2. 19.5.2. Looking at the Actual Trigger
        3. 19.5.3. The ORA_SPACE_ERROR_INFO Function
        4. 19.5.4. The DBMS_RESUMABLE Package
        5. 19.5.5. Trapped Multiple Times
        6. 19.5.6. To Fix or Not to Fix?
      6. 19.6. Maintaining Triggers
        1. 19.6.1. Disabling, Enabling, and Dropping Triggers
        2. 19.6.2. Viewing Triggers
        3. 19.6.3. Checking the Validity of Triggers
    4. 20. Managing PL/SQL Code
      1. 20.1. Managing Code in the Database
        1. 20.1.1. Data Dictionary Views for PL/SQL Programmers
          1. 20.1.1.1. Display information about stored objects
          2. 20.1.1.2. Display and search source code
          3. 20.1.1.3. Use program size to determine pinning requirements
          4. 20.1.1.4. Obtain properties of stored code
          5. 20.1.1.5. Analyze and modify trigger state through views
          6. 20.1.1.6. Analyze argument information
        2. 20.1.2. Recompiling Invalid Code
          1. 20.1.2.1. Recompile individual program units
          2. 20.1.2.2. Use UTL_RECOMP
      2. 20.2. Using Native Compilation
        1. 20.2.1. Perform One-Time DBA Setup
        2. 20.2.2. Step 1: Get a Supported C Compiler
        3. 20.2.3. Step 2: Set Up the Directories
        4. 20.2.4. Step 3: Check $ORACLE_HOME/plsql/spnc_commands
        5. 20.2.5. Interpreted Versus Native Compilation Mode
      3. 20.3. Using the Optimizing Compiler and Compile-Time Warnings
        1. 20.3.1. The Optimizing Compiler
        2. 20.3.2. Compile-Time Warnings
          1. 20.3.2.1. A quick example
          2. 20.3.2.2. If you see a “no message file” message
          3. 20.3.2.3. Verify your SQL*Plus version
          4. 20.3.2.4. How to turn on compile-time warnings
        3. 20.3.3. Warnings Available in Oracle Database 10g
          1. 20.3.3.1. PLW-05000: mismatch in NOCOPY qualification between specification and body
          2. 20.3.3.2. PLW-05001: previous use of ’string’ (at line string) conflicts with this use
          3. 20.3.3.3. PLW-05003: same actual parameter(string and string) at IN and NOCOPY may have side effects
          4. 20.3.3.4. PLW-05004: identifier string is also declared in STANDARD or is a SQL built-in
          5. 20.3.3.5. PLW-05005: function string returns without value at line string
          6. 20.3.3.6. PLW-06002: unreachable code
          7. 20.3.3.7. PLW-07203: parameter ’string’ may benefit from use of the NOCOPY compiler hint
          8. 20.3.3.8. PLW-07204: conversion away from column type may result in sub-optimal query plan
      4. 20.4. Conditional Compilation
        1. 20.4.1. Examples of Conditional Compilation
          1. 20.4.1.1. Use application package constants in $IF directive
          2. 20.4.1.2. Toggle tracing through conditional compilation flags
        2. 20.4.2. The Inquiry Directive
          1. 20.4.2.1. The DBMS_DB_VERSION package
          2. 20.4.2.2. Setting compilation environment parameters
          3. 20.4.2.3. Referencing unit name and line number
          4. 20.4.2.4. Using the PLSQL_CCFLAGS parameter
        3. 20.4.3. The $IF Directive
        4. 20.4.4. The $ERROR Directive
        5. 20.4.5. Synchronizing Code with Packaged Constants
        6. 20.4.6. Program-Specific Settings with Inquiry Directives
        7. 20.4.7. Working with Postprocessed Code
      5. 20.5. Testing PL/SQL Programs
        1. 20.5.1. Typical, Tawdry Testing Techniques
        2. 20.5.2. utPLSQL: A Unit-Testing Framework
          1. 20.5.2.1. Using utPLSQL with betwnstr
          2. 20.5.2.2. Where to find utPLSQL and Ounit
      6. 20.6. Debugging PL/SQL Programs
        1. 20.6.1. The Wrong Way to Debug
          1. 20.6.1.1. Disorganized debugging
          2. 20.6.1.2. Irrational debugging
        2. 20.6.2. Debugging Tips and Strategies
          1. 20.6.2.1. Use a source code debugger
          2. 20.6.2.2. Gather data
          3. 20.6.2.3. Remain logical at all times
          4. 20.6.2.4. Analyze instead of trying
          5. 20.6.2.5. Take breaks, and ask for help
          6. 20.6.2.6. Change and test one area of code at a time
        3. 20.6.3. Tracing Execution of Your Code
          1. 20.6.3.1. DBMS_UTILITY.FORMAT_CALL_STACK
          2. 20.6.3.2. Installing DBMS_TRACE
          3. 20.6.3.3. DBMS_TRACE programs
          4. 20.6.3.4. Controlling trace file contents
          5. 20.6.3.5. Pausing and resuming the trace process
          6. 20.6.3.6. Format of collected data
      7. 20.7. Tuning PL/SQL Programs
        1. 20.7.1. Analyzing Performance of PL/SQL Code
        2. 20.7.2. Optimizing PL/SQL Performance
          1. 20.7.2.1. Use the most aggressive compiler optimization level possible
          2. 20.7.2.2. Use BULK COLLECT when querying multiple rows
          3. 20.7.2.3. Use FORALL when modifying multiple rows
          4. 20.7.2.4. Use the NOCOPY hint when passing large structures
          5. 20.7.2.5. Use PLS_INTEGER for intensive integer computations.
          6. 20.7.2.6. Use BINARY_FLOAT or BINARY_DOUBLE for floating-point arithmetic
          7. 20.7.2.7. Group together related programs in a package
          8. 20.7.2.8. Pin into shared memory large and frequently executed programs.
      8. 20.8. Protecting Stored Code
        1. 20.8.1. Restrictions on and Limitations of Wrapping
        2. 20.8.2. Using the Wrap Executable
        3. 20.8.3. Dynamic Wrapping with DBMS_DDL
        4. 20.8.4. Guidelines for Working with Wrapped Code
    5. 21. I/O and PL/SQL
      1. 21.1. Displaying Information
        1. 21.1.1. Enabling DBMS_OUTPUT
        2. 21.1.2. Write Lines to a Buffer
        3. 21.1.3. Read the Contents of a Buffer
      2. 21.2. Reading and Writing Files
        1. 21.2.1. The UTL_FILE_DIR Parameter
          1. 21.2.1.1. Setting up directories
          2. 21.2.1.2. Specifying file locations
        2. 21.2.2. Work with Oracle Directories
        3. 21.2.3. Open Files
        4. 21.2.4. Is the File Already Open?
        5. 21.2.5. Close Files
        6. 21.2.6. Read from Files
          1. 21.2.6.1. GET_LINE exceptions
          2. 21.2.6.2. Handy encapsulation for GET_LINE
        7. 21.2.7. Write to Files
          1. 21.2.7.1. Writing formatted text to file
        8. 21.2.8. Copy Files
        9. 21.2.9. Delete Files
        10. 21.2.10. Rename and Move Files
        11. 21.2.11. Retrieve File Attributes
      3. 21.3. Sending Email
        1. 21.3.1. Oracle Prerequisites by Release
        2. 21.3.2. Send a Short (32K or Less) Plaintext Message
        3. 21.3.3. Include “Friendly” Names in Email Addresses
        4. 21.3.4. Send a Plaintext Message of Arbitrary Length
        5. 21.3.5. Send a Message with a Short (< 32K) Attachment
        6. 21.3.6. Send a Small File (< 32K) as an Attachment
        7. 21.3.7. Attach a File of Arbitrary Size
      4. 21.4. Working with Web-Based Data (HTTP)
        1. 21.4.1. Retrieve a Web Page in “Pieces”
        2. 21.4.2. Retrieve a Web Page into a LOB
        3. 21.4.3. Authenticate Using HTTP Username/Password
        4. 21.4.4. Retrieve an SSL-Encrypted Web Page (Via https)
        5. 21.4.5. Submit Data to a Web Page via GET or POST
        6. 21.4.6. Disable Cookies or Make Cookies Persistent
        7. 21.4.7. Retrieve Data from an FTP Server
        8. 21.4.8. Use a Proxy Server
      5. 21.5. Other Types of I/O Available in PL/SQL
        1. 21.5.1. Database Pipes, Queues, and Alerts
        2. 21.5.2. TCP Sockets
        3. 21.5.3. Oracle’s Built-in Web Server
  10. VI. Advanced PL/SQL Topics
    1. 22. Application Security and PL/SQL
      1. 22.1. Security Overview
      2. 22.2. Encryption
        1. 22.2.1. Key Length
        2. 22.2.2. Algorithms
        3. 22.2.3. Padding and Chaining
        4. 22.2.4. The DBMS_CRYPTO Package
          1. 22.2.4.1. Algorithms
          2. 22.2.4.2. Padding and chaining
        5. 22.2.5. Encrypting Data
        6. 22.2.6. Encrypting LOBs
        7. 22.2.7. Decrypting Data
        8. 22.2.8. Performing Key Generation
        9. 22.2.9. Performing Key Management
          1. 22.2.9.1. A single key for the database
          2. 22.2.9.2. A single key for each row
          3. 22.2.9.3. A combined approach
        10. 22.2.10. Cryptographic Hashing
        11. 22.2.11. Using Message Authentication Code
        12. 22.2.12. Using Transparent Data Encryption (TDE)
      3. 22.3. Row-Level Security
        1. 22.3.1. Why Learn About RLS?
        2. 22.3.2. A Simple RLS Example
        3. 22.3.3. Using Dynamic Policies
          1. 22.3.3.1. Shared static policy
          2. 22.3.3.2. Context-sensitive policy
          3. 22.3.3.3. Shared context sensitive policy
        4. 22.3.4. Using Column-Sensitive RLS
        5. 22.3.5. RLS Debugging
          1. 22.3.5.1. Interpreting errors
          2. 22.3.5.2. Performing direct path operations
          3. 22.3.5.3. Viewing SQL statements
      4. 22.4. Application Contexts
        1. 22.4.1. Using Application Contexts
        2. 22.4.2. Security in Contexts
        3. 22.4.3. Contexts as Predicates in RLS
        4. 22.4.4. Identifying Non-Database Users
      5. 22.5. Fine-Grained Auditing
        1. 22.5.1. Why Learn About FGA?
        2. 22.5.2. A Simple FGA Example
        3. 22.5.3. Access How Many Columns?
        4. 22.5.4. Checking the Audit Trail
        5. 22.5.5. Using Bind Variables
        6. 22.5.6. Using Handler Modules
    2. 23. Inside PL/SQL
      1. 23.1. Looking Under the Hood
        1. 23.1.1. PL/SQL Concepts
        2. 23.1.2. Physical Storage of Server-Side PL/SQL
        3. 23.1.3. Compiler Limits
      2. 23.2. PL/SQL’s Optimizing Compiler
        1. 23.2.1. Runtime Optimization of Fetch Loops
      3. 23.3. Dependency Management
        1. 23.3.1. Dependencies in Server-Side PL/SQL
        2. 23.3.2. Healing Invalids
          1. 23.3.2.1. Recompiling by hand
          2. 23.3.2.2. Recompiling by script
          3. 23.3.2.3. Automatic recompilation
        3. 23.3.3. Remote Dependencies
      4. 23.4. Execution Authority Models
        1. 23.4.1. The Definer Rights Model
          1. 23.4.1.1. Advantages of definer rights
          2. 23.4.1.2. Disadvantages of definer rights
            1. 23.4.1.2.1. Where’d my table go?
            2. 23.4.1.2.2. How do I maintain all that code?
            3. 23.4.1.2.3. Dynamic SQL and definer rights.
        2. 23.4.2. The Invoker Rights Model
          1. 23.4.2.1. Invoker rights syntax
          2. 23.4.2.2. Some rules and restrictions
        3. 23.4.3. Combining Rights Models
      5. 23.5. PL/SQL and Oracle Memory
        1. 23.5.1. PGA, UGA, and CGA
        2. 23.5.2. Cursors, Memory, and More
        3. 23.5.3. Tips on Reducing Memory Use
          1. 23.5.3.1. Statement sharing
          2. 23.5.3.2. Bind variables
          3. 23.5.3.3. Packaging to improve memory use and performance
          4. 23.5.3.4. Large collections in PL/SQL
          5. 23.5.3.5. Preservation of state
        4. 23.5.4. What to Do if You Run Out of Memory
      6. 23.6. Server-Side PL/SQL Processing: Reprise
        1. 23.6.1. Compiling an Anonymous Block
        2. 23.6.2. Compiling a Stored Object
        3. 23.6.3. Executing PL/SQL
      7. 23.7. What You Need to Know
    3. 24. Globalization and Localization in PL/SQL
      1. 24.1. Overview and Terminology
      2. 24.2. Unicode Primer
        1. 24.2.1. National Character Set Datatypes
        2. 24.2.2. Character Encoding
        3. 24.2.3. Globalization Support Parameters
        4. 24.2.4. Unicode Functions
          1. 24.2.4.1. ASCIISTR
          2. 24.2.4.2. COMPOSE
          3. 24.2.4.3. DECOMPOSE
          4. 24.2.4.4. INSTR/INSTRB/INSTRC/INSTR2/INSTR4
          5. 24.2.4.5. LENGTH/LENGTHB/LENGTHC/LENGTH2/LENGTH4
          6. 24.2.4.6. SUBSTR/SUBSTRB/SUBSTRC/SUBSTR2/SUBSTR4
          7. 24.2.4.7. UNISTR
      3. 24.3. Character Semantics
      4. 24.4. String Sort Order
        1. 24.4.1. Binary Sort
        2. 24.4.2. Monolingual Sort
        3. 24.4.3. Multilingual Sort
      5. 24.5. Multilingual Information Retrieval
        1. 24.5.1. IR and PL/SQL
      6. 24.6. Date/Time
        1. 24.6.1. Timestamp Datatypes
        2. 24.6.2. Date/Time Formatting
      7. 24.7. Currency Conversion
      8. 24.8. Globalization Development Kit for PL/SQL
        1. 24.8.1. UTL_118N Utility Package
        2. 24.8.2. UTL_LMS Error-Handling Package
        3. 24.8.3. GDK Implementation Options
          1. 24.8.3.1. Method 1: Locale buttons
          2. 24.8.3.2. Method 2: User administration
          3. 24.8.3.3. Method 3: Hybrid
    4. 25. Object-Oriented Aspects of PL/SQL
      1. 25.1. Introduction to Oracle’s Object Features
      2. 25.2. An Extended Example
        1. 25.2.1. A Tree of Types
          1. 25.2.1.1. Creating a base type
          2. 25.2.1.2. Creating a subtype
        2. 25.2.2. Methods
        3. 25.2.3. Storing, Retrieving, and Using Persistent Objects
          1. 25.2.3.1. Object identity
          2. 25.2.3.2. The VALUE function
          3. 25.2.3.3. The TREAT function
        4. 25.2.4. Evolution and Creation
        5. 25.2.5. Back to Pointers?
          1. 25.2.5.1. Using REFs
          2. 25.2.5.2. The UTL_REF package
          3. 25.2.5.3. REFs and type hierarchies
          4. 25.2.5.4. Dangling REFs
        6. 25.2.6. Generic Data: The ANY Types
          1. 25.2.6.1. Preview: What ANYDATA is not
          2. 25.2.6.2. Dealing with an ANYDATA
          3. 25.2.6.3. Creating a transient type
        7. 25.2.7. I Can Do It Myself
        8. 25.2.8. Comparing Objects
          1. 25.2.8.1. Attribute-level comparison
          2. 25.2.8.2. The MAP method
          3. 25.2.8.3. The ORDER method
          4. 25.2.8.4. Additional comparison recommendations
      3. 25.3. Object Views
        1. 25.3.1. A Sample Relational System
        2. 25.3.2. Object View with a Collection Attribute
        3. 25.3.3. Object Subview
        4. 25.3.4. Object View with Inverse Relationship
        5. 25.3.5. INSTEAD OF Triggers
          1. 25.3.5.1. The case against
          2. 25.3.5.2. The case for
          3. 25.3.5.3. The bigger question
        6. 25.3.6. Differences Between Object Views and Object Tables
          1. 25.3.6.1. OID uniqueness
          2. 25.3.6.2. “Storeability” of physical versus virtual REFs
          3. 25.3.6.3. REFs to nonunique OIDs
      4. 25.4. Maintaining Object Types and Object Views
        1. 25.4.1. Privileges
          1. 25.4.1.1. The EXECUTE privilege
          2. 25.4.1.2. The UNDER privilege
          3. 25.4.1.3. The DEBUG privilege
          4. 25.4.1.4. The DML privileges
      5. 25.5. Pontifications
    5. 26. Calling Java from PL/SQL
      1. 26.1. Oracle and Java
      2. 26.2. Getting Ready to Use Java in Oracle
        1. 26.2.1. Installing Java
        2. 26.2.2. Building and Compiling Your Java Code
        3. 26.2.3. Setting Permissions for Java Development and Execution
          1. 26.2.3.1. Java security for Oracle through 8.1.5
          2. 26.2.3.2. Java security for Oracle for 8.1.6 through Oracle Database 10g
      3. 26.3. A Simple Demonstration
        1. 26.3.1. Finding the Java Functionality
        2. 26.3.2. Building a Custom Java Class
        3. 26.3.3. Compiling and Loading into Oracle
        4. 26.3.4. Building a PL/SQL Wrapper
        5. 26.3.5. Deleting Files from PL/SQL
      4. 26.4. Using loadjava
      5. 26.5. Using dropjava
      6. 26.6. Managing Java in the Database
        1. 26.6.1. The Java Namespace in Oracle
        2. 26.6.2. Examining Loaded Java Elements
      7. 26.7. Using DBMS_JAVA
        1. 26.7.1. LONGNAME: Converting Java Long Names
        2. 26.7.2. GET_, SET_, and RESET_COMPILER_OPTION: Getting and Setting (a Few) Compiler Options
        3. 26.7.3. SET_OUTPUT: Enabling Output from Java
        4. 26.7.4. EXPORT_SOURCE, EXPORT_RESOURCE, and EXPORT_CLASS: Exporting Schema Objects
      8. 26.8. Publishing and Using Java in PL/SQL
        1. 26.8.1. Call Specs
        2. 26.8.2. Some Rules for Call Specs
        3. 26.8.3. Mapping Datatypes
        4. 26.8.4. Calling a Java Method in SQL
        5. 26.8.5. Exception Handling with Java
        6. 26.8.6. Extending File I/O Capabilities
          1. 26.8.6.1. Polishing up the delete method
          2. 26.8.6.2. Obtaining directory contents
        7. 26.8.7. Other Examples
    6. 27. External Procedures
      1. 27.1. Introduction to External Procedures
        1. 27.1.1. Example: Invoking an Operating System Command
        2. 27.1.2. Architecture of External Procedures
      2. 27.2. The Oracle Net Configuration
        1. 27.2.1. Specifying the Listener Configuration
        2. 27.2.2. Security Characteristics of the Configuration
      3. 27.3. Setting Up Multithreaded Mode
      4. 27.4. Creating an Oracle Library
      5. 27.5. Writing the Call Specification
        1. 27.5.1. The Call Spec: Overall Syntax
        2. 27.5.2. Parameter Mapping: The Example Revisited
        3. 27.5.3. Parameter Mapping: The Full Story
        4. 27.5.4. More Syntax: The PARAMETERS Clause
        5. 27.5.5. PARAMETERS Properties
          1. 27.5.5.1. The INDICATOR property
          2. 27.5.5.2. The LENGTH property
          3. 27.5.5.3. The MAXLEN property
          4. 27.5.5.4. The CHARSETID and CHARSETFORM properties
      6. 27.6. Raising an Exception from the Called C Program
      7. 27.7. Nondefault Agents
      8. 27.8. Maintaining External Procedures
        1. 27.8.1. Dropping Libraries
        2. 27.8.2. Data Dictionary
        3. 27.8.3. Rules and Warnings
  11. VII. Appendixes
    1. A. Regular Expression Metacharacters and Function Parameters
      1. A.1. Metacharacters
      2. A.2. Function Parameters
    2. B. Number Format Models
    3. C. Date Format Models
  12. About the Authors
  13. Colophon
  14. Copyright

Product information

  • Title: Oracle PL/SQL Programming, 4th Edition
  • Author(s): Steven Feuerstein, Bill Pribyl
  • Release date: August 2005
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596009779