175. Introduction to Oracle10g PL/SQL
Programming
Rev. 4.2.2
The Oracle10g release has greatly enhanced the features and
functionality of PL/SQL. Students will learn the fundamentals of the PL/SQL
programming language. Students will write stored procedures, functions,
packages, and triggers, and implement complex business rules in Oracle.
Students will learn programming, management, and security issues of working
with PL/SQL program units. Programming topics will include the built-in
packages that come with Oracle, the creation of triggers, and stored procedure
features.
LEARNING OBJECTIVES
·
Gain a working knowledge of programming Oracle
10g databases using the PL/SQL language
·
Learn the use of stored procedures, functions,
packages and triggers
·
Understand management and security issues in
working with PL/SQL
Course Duration: 3 days
Audience: Application
developers and database administrators.
Prerequisite: A solid understanding of SQL and procedural
programming is required. It is recommended the student understand Oracle10g SQL
features.
1.
Course Introduction
Course Objectives
Course Overview
Using the Workbook
Suggested References
2.
Triggers
Beyond Declarative Integrity
Triggers
Types of Triggers
Row-Level Triggers
Cascading Triggers and Mutating Tables
Generating an Error
Triggers on Views
System Triggers
Maintaining Triggers
3.
PL/SQL Variables and Datatypes
Declaring Variables
Datatypes
Subtypes
Character Data
Dates and Timestamps
Date Intervals
Anchored Types
Assignment and Conversions
Selecting into a Variable
4.
PL/SQL Syntax and Logic
PL/SQL Blocks and Programs
Conditional Statements - IF/THEN
Conditional Statements - CASE
Comments and Labels
Loops
WHILE and FOR Loops
5.
Stored Procedures and Functions
Stored Subprograms
Procedures and Functions
Creating a Stored Procedure
Calling a Stored Procedure
Passing Parameters and Default Arguments
Parameter Modes
Creating a Stored Function
Calling a Stored Function
Stored Functions and SQL
Local Procedures and Functions
6.
Exception Handling
SQLCODE and SQLERRM
Exception Handlers
Nesting Blocks
Scope and Name Resolution
User-Defined Exceptions
Compile-Time Warnings
7.
Records and Collections
Record Variables
Using the %ROWTYPE Attribute
VARRAY and Nested TABLE Collections
Using Nested TABLEs
Using VARRAYs
Associative Array Collections
Collection Methods
Iterating Through Collections
FORALL Statement
BULK COLLECT Clause
8.
Cursors
Multi-Row Queries
Declaring and Opening Cursors
Fetching Rows
Closing Cursors
The Cursor FOR Loop
FOR UPDATE Cursors
Cursor Parameters
The Implicit (SQL) Cursor
9.
Using Packages
Packages
Oracle-Supplied Packages
The DBMS_OUTPUT Package
The DBMS_UTILITY Package
The UTL_FILE Package
The DBMS_METADATA Package
XML Packages
Networking Packages
Other Supplied Packages
10. Creating
Packages
Structure of a Package
The Package Interface and Implementation
Package Variables
Overloading Package Functions and Procedures
Named Parameter Notation
REF CURSOR Variables
11. Working
with LOBS
Large Object Types
Oracle Directories
LOB Locators
Internal LOBs
External LOBs
Temporary LOBs
The DBMS_LOB Package
12. Maintaining
PL/SQL Code
Privileges for Stored Programs
PL/SQL Stored Program Compilation
The PL/SQL Execution Environment
Dependencies and Validation
Maintaining Stored Programs
Appendix A. Dynamic SQL
Generating SQL at Runtime
Native Dynamic SQL vs. DBMS_SQL Package
The EXECUTE IMMEDIATE Statement
Using Bind Variables
Multi-row Dynamic Queries
Bulk Operations with Dynamic SQL
Using DBMS_SQL
DBMS_SQL Subprograms
Appendix B. PL/SQL Versions,
Datatypes and Language Limits
Appendix C. Oracle10g
Supplied Packages
System Requirements
Course exercises require Oracle 10g running on a Microsoft Windows,
Linux, or multi-user UNIX system. See the
appropriate course Setup Guide for details.
A good minimal hardware profile for this course would have a Pentium
500-MHz or equivalent CPU, 512 MB of RAM, and at least 4 GB of free disk space
for the Oracle installation.