Tải bản đầy đủ (.pdf) (322 trang)

SQL and PL/SQL Using Procedure Buider

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.81 MB, 322 trang )

Introduction to Oracle: SQL
and PL/SQL Using Procedure
Builder
Volume One
S
Participant Guide
Edition 1.1
M03989
T1001E11
Authors
Neena Kochhar
Debby Kramer
Technical Contributors
and Reviewers
Christian Bauwens
Debra Bowman
Lenny Brunson
Jackie Collins
Ralf Durben
Brian Fry
Anthony Holbrook
Karlene Jensen
Sarah Jones
Glenn Maslen
Sundar Nagarathnam
Sandra Schrick
Ulrike Schwinn
Rosemarie Truman
Jenny Tsai
Laura Van Deusen
Publishers


Stephanie Jones
Kimberly Lee
Jennifer Robertson
Mark Turangan
Copyright EĂOracle Corporation, 1992, 1996. All rights reserved.
This documentation contains proprietary information of Oracle Corporation; it is
provided under a license agreement containing restrictions on use and discloĆ
sure and is also protected by copyright law. Reverse engineering of the software
is prohibited. If this documentation is delivered to a U.S. Government Agency of
the Department of Defense, then it is delivered with Restricted Rights and the folĆ
lowing legend is applicable:
Restricted Rights Legend
Use, duplication or disclosure by the Government is subject to restrictions for
commercial computer software and shall be deemed to be Restricted Rights softĆ
ware under Federal law, and as set forth in subparagraph (c) (1) (ii) of DFARS
252.227Ć7013, Rights in Technical Data and Computer Software (October 1988).
This material or any portion of it may not be copied in any form or by any means
without the express prior written permission of the Worldwide Education Services
group of Oracle Corporation. Any other copying is a violation of copyright law and
may result in civil and/or criminal penalties.
If this documentation is delivered to a U.S. Government Agency not within the DeĆ
partment of Defense, then it is delivered with Restricted Rights," as defined in
FAR 52.227Ć14, Rights in DataĆGeneral, including Alternate III (June 1987).
The information in this document is subject to change without notice. If you find
any problems in the documentation, please report them in writing to Worldwide
Education Services, Oracle Corporation, 500 Oracle Parkway, Box 659806, RedĆ
wood Shores, CA 94065. Oracle Corporation does not warrant that this document
is error free.
SQL*Plus, PL/SQL, Procedure Builder, Developer/2000, Oracle7 Server, Oracle
Server, Discoverer/2000, and Designer/2000 are trademarks or registered tradeĆ

marks of Oracle Corporation.
All other products or company names are used for identification purposes only,
and may be trademarks of their respective owners.
iii
Contents
Volume 1
Preface xi....................................................................
Profile xii.................................................................
Related Publications xviii....................................................
Typographic Conventions xix................................................
I Introduction IĆ1...........................................................
Course Objectives IĆ3......................................................
Course Outline IĆ5.........................................................
The Relational Database Concept IĆ9........................................
System Development Cycle IĆ17..............................................
What Is Oracle? IĆ19........................................................
The Oracle Product Set IĆ21..................................................
SQL, SQL*Plus, and PL/SQL IĆ23.............................................
Summit Sporting Goods Demonstration Tables IĆ29.............................
Summary IĆ33..............................................................
1. Selecting Rows 1Ć1........................................................
Objectives 1Ć3.............................................................
The Basic Query Block 1Ć5..................................................
Arithmetic Expressions 1Ć13..................................................
Column Aliases 1Ć21........................................................
The Concatenation Operator 1Ć23.............................................
Literal Character String 1Ć25..................................................
Managing Null Values 1Ć27...................................................
Preventing the Selection of Duplicate Rows 1Ć31................................
SQL*Plus Commands 1Ć35...................................................

Logging in to SQL*Plus 1Ć37.................................................
Displaying Table Structure 1Ć39...............................................
SQL*Plus Editing Commands 1Ć41............................................
SQL*Plus File Commands and Online Help 1Ć43................................
Creating a Report 1Ć45.......................................................
Summary 1Ć51..............................................................
Practice Overview 1Ć53......................................................
Practice 1 1Ć55..............................................................
2. Limiting Selected Rows 2Ć1................................................
Objectives 2Ć3.............................................................
Ordering Rows with the ORDER BY Clause 2Ć5................................
Limiting Selected Rows with the WHERE Clause 2Ć11............................
Comparison Operators 2Ć13..................................................
iv
Negating Expressions 2Ć17...................................................
SQL Operators 2Ć19.........................................................
Querying Data with Multiple Conditions 2Ć27....................................
Rules of Precedence 2Ć29....................................................
Summary 2Ć33..............................................................
Practice Overview 2Ć35......................................................
Practice 2 2Ć37..............................................................
3. Single Row Functions 3Ć1..................................................
Objectives 3Ć3.............................................................
Overview 3Ć5..............................................................
Single Row Functions 3Ć7...................................................
Character Functions 3Ć9....................................................
Number Functions 3Ć17......................................................
Oracle Date Format 3Ć23.....................................................
Using Arithmetic Operators with Dates 3Ć25....................................
Date Functions 3Ć27.........................................................

Conversion Functions 3Ć33...................................................
TO_CHAR Function with Date Formats 3Ć35....................................
TO_CHAR Function with Number Formats 3Ć45.................................
TO_NUMBER and TO_DATE Functions 3Ć49....................................
Nesting Single Row Functions 3Ć51............................................
Nesting Functions 3Ć53......................................................
Summary 3Ć55..............................................................
Practice Overview 3Ć57......................................................
Practice 3 3Ć59..............................................................
4. Displaying Data from Multiple Tables 4Ć1....................................
Objectives 4Ć3.............................................................
Overview 4Ć5..............................................................
What Is a Cartesian Product? 4Ć7............................................
Simple Join Query 4Ć9......................................................
Using Table Aliases 4Ć17.....................................................
NonĆEquijoin 4Ć19...........................................................
Returning Records with No Direct Match 4Ć21...................................
Joining a Table to Itself 4Ć25..................................................
Summary 4Ć27..............................................................
Practice Overview 4Ć29......................................................
Practice 4 4Ć31..............................................................
5. Group Functions 5Ć1.......................................................
Objectives 5Ć3.............................................................
Overview 5Ć5..............................................................
Group Functions 5Ć7.......................................................
v
The GROUP BY Clause 5Ć13..................................................
Illegal Queries Using Group Functions 5Ć19....................................
Groups Within Groups 5Ć23..................................................
The HAVING Clause 5Ć25....................................................

Summary 5Ć31..............................................................
Practice Overview 5Ć33......................................................
Practice 5 5Ć34..............................................................
6. Subqueries 6Ć1............................................................
Objectives 6Ć3.............................................................
Overview 6Ć5..............................................................
Subqueries 6Ć7............................................................
How Are Nested Subqueries Processed? 6Ć9..................................
Single Row Subqueries 6Ć11..................................................
Errors with Subqueries 6Ć15..................................................
Multiple Row Subqueries 6Ć17................................................
HAVING Clause with Nested Subqueries 6Ć19..................................
Summary 6Ć21..............................................................
Practice Overview 6Ć23......................................................
Practice 6 6Ć25..............................................................
Volume 2
7. Specifying Variables at Runtime 7Ć1........................................
Objectives 7Ć3.............................................................
Overview 7Ć5..............................................................
Substitution Variables 7Ć7...................................................
Single Ampersand Substitution Variables 7Ć9..................................
Defining User Variables 7Ć15..................................................
Passing Values into a Script File 7Ć21..........................................
Summary 7Ć23..............................................................
Practice Overview 7Ć25......................................................
Practice 7 7Ć26..............................................................
8. Overview of Data Modeling and Database Design 8Ć1........................
Objectives 8Ć3.............................................................
Overview 8Ć5..............................................................
System Development Cycle 8Ć7..............................................

Database Design 8Ć9.......................................................
Data Model 8Ć11............................................................
Entity Relationship Modeling 8Ć13.............................................
Entity Relationship Model Concepts 8Ć15.......................................
Integrity Constraints and Keys 8Ć23............................................
Designing the Database 8Ć29.................................................
Summary 8Ć39..............................................................
vi
9. Creating Tables 9Ć1........................................................
Objectives 9Ć3.............................................................
Overview 9Ć5..............................................................
Creating Tables 9Ć7.........................................................
Oracle7 Datatypes 9Ć13......................................................
Constraints 9Ć15............................................................
Creating a Table from a Table Instance Chart 9Ć25...............................
Creating a Table from Rows in Another Table 9Ć31...............................
Confirming Table Creation 9Ć33...............................................
Summary 9Ć35..............................................................
Practice Overview 9Ć37......................................................
Practice 9 9Ć39..............................................................
10. Oracle Data Dictionary 10Ć1.................................................
Objectives 10Ć3.............................................................
Overview 10Ć5..............................................................
Querying the Data Dictionary 10Ć7.............................................
Checking Constraints on a Table 10Ć13.........................................
Summary 10Ć17..............................................................
Practice Overview 10Ć19......................................................
Practice 10 10Ć21............................................................
11. Manipulating Data 11Ć1.....................................................
Objectives 11Ć3.............................................................

Overview 11Ć5..............................................................
Adding a New Row to a Table 11Ć7............................................
Copying Rows from Another Table 11Ć19........................................
Updating Rows 11Ć21.........................................................
Deleting Rows 11Ć29..........................................................
Transaction Processing 11Ć35..................................................
Committing Changes 11Ć39...................................................
Rolling Back Changes 11Ć43...................................................
Rolling Back Changes to a Savepoint 11Ć45.....................................
Statement Level Rollback 11Ć47................................................
Summary 11Ć49..............................................................
Practice Overview 11Ć51......................................................
Practice 11 11Ć53............................................................
12. Altering Tables and Constraints 12Ć1.........................................
Objectives 12Ć3.............................................................
Overview 12Ć5..............................................................
Adding a Column 12Ć7.......................................................
Modifying a Column 12Ć9....................................................
Adding and Dropping a Constraint 12Ć11........................................
vii
Disabling and Enabling a Constraint 12Ć15......................................
Dropping a Table 12Ć17.......................................................
Renaming and Truncating a Table 12Ć19........................................
Adding a Comment to a Table 12Ć21............................................
Summary 12Ć23..............................................................
Practice Overview 12Ć25......................................................
Practice 12 12Ć27............................................................
13. Creating Sequences 13Ć1...................................................
Objectives 13Ć3.............................................................
Overview 13Ć5..............................................................

Creating a Sequence 13Ć7....................................................
Using a Sequence 13Ć13......................................................
Altering a Sequence 13Ć17....................................................
Removing a Sequence 13Ć19..................................................
Summary 13Ć21..............................................................
Practice Overview 13Ć23......................................................
Practice 13 13Ć25............................................................
14. Creating Views 14Ć1........................................................
Objectives 14Ć3.............................................................
Overview 14Ć5..............................................................
Creating a View 14Ć7........................................................
Performing DML Operations on a View 14Ć15....................................
Confirming View Names and Structures 14Ć21...................................
Removing a View 14Ć23.......................................................
Summary 14Ć25..............................................................
Practice Overview 14Ć27......................................................
Practice 14 14Ć29............................................................
15. Creating Indexes 15Ć1......................................................
Objectives 15Ć3.............................................................
Overview 15Ć5..............................................................
When Is the Index Used? 15Ć7................................................
Index Structure 15Ć9.........................................................
Creating an Index 15Ć13.......................................................
Confirming Indexes 15Ć17.....................................................
Removing an Index 15Ć19.....................................................
Summary 15Ć21..............................................................
Practice Overview 15Ć23......................................................
Practice 15 15Ć25............................................................
16. Controlling User Access 16Ć1...............................................
Objectives 16Ć3.............................................................

Overview 16Ć5..............................................................
viii
System Privileges 16Ć7.......................................................
What Is a Role? 16Ć11........................................................
Changing Your Password 16Ć13................................................
Granting Object Privileges 16Ć15...............................................
Confirming Privileges Granted 16Ć21............................................
Revoking Object Privileges 16Ć23..............................................
Creating a Synonym for an Object 16Ć25........................................
Summary 16Ć29..............................................................
Practice Overview 16Ć31......................................................
Practice 16 16Ć33............................................................
17. Summary of SQL and SQL*Plus 17Ć1........................................
Summary of SQL and SQL*Plus 17Ć3..........................................
Practice Overview 17Ć9......................................................
Practice 17 17Ć11............................................................
Volume 3
18. Overview of PL/SQL 18Ć1...................................................
Objectives 18Ć3.............................................................
Overview 18Ć5..............................................................
PL/SQL Block Structure 18Ć9.................................................
The PL/SQL Environment 18Ć15................................................
About Procedure Builder 18Ć17................................................
19. Basics of Procedure Builder 19Ć1............................................
Objectives 19Ć3.............................................................
Overview 19Ć5..............................................................
Oracle Procedure Builder Capabilities 19Ć7.....................................
Procedure Builder Components 19Ć9..........................................
The Object Navigator 19Ć15...................................................
The Interpreter 19Ć23.........................................................

The Program Unit Editor 19Ć27.................................................
The Stored Program Unit Editor 19Ć31..........................................
Debugging a Stored Program Unit 19Ć33........................................
Performing Debug Actions in the Interpreter 19Ć35................................
Setting a Breakpoint 19Ć37....................................................
Examining Local Variables 19Ć43...............................................
Summary 19Ć45..............................................................
Practice Overview 19Ć47......................................................
Practice 19 19Ć49............................................................
20. Modularizing Programming with Subprograms 20Ć1...........................
Objectives 20Ć3.............................................................
Overview 20Ć5..............................................................
ix
Creating a Subprogram 20Ć7.................................................
Creating a Procedure 20Ć9...................................................
Comparing Functions and Procedures 20Ć15....................................
Creating a Function 20Ć17.....................................................
Invoking Subprograms 20Ć21..................................................
Summary 20Ć29..............................................................
Practice Overview 20Ć31......................................................
Practice 20 20Ć33............................................................
21. Developing a Simple PL/SQL Block 21Ć1.....................................
Objectives 21Ć3.............................................................
Overview 21Ć5..............................................................
Declaring PL/SQL Variables and Constants 21Ć7................................
Declaring Scalar Variables 21Ć9...............................................
Declaring Composite Datatypes 21Ć15..........................................
PL/SQL Block Syntax Rules 21Ć25..............................................
Assigning Values to Variables 21Ć29............................................
Programming Guidelines 21Ć43................................................

Summary 21Ć49..............................................................
Practice Overview 21Ć51......................................................
Practice 21 21Ć53............................................................
22. Interacting with Oracle 22Ć1.................................................
Objectives 22Ć3.............................................................
Overview 22Ć5..............................................................
Retrieving Data Using PL/SQL 22Ć7............................................
SELECT Exceptions 22Ć15.....................................................
Manipulating Data Using PL/SQL 22Ć19.........................................
SQL Cursor 22Ć23............................................................
Controlling Transactions 22Ć27.................................................
Summary 22Ć31..............................................................
Practice Overview 22Ć33......................................................
Practice 22 22Ć35............................................................
23. Controlling Flow in PL/SQL Blocks 23Ć1......................................
Objectives 23Ć3.............................................................
Overview 23Ć5..............................................................
The IF Statement 23Ć7.......................................................
Building Logical Conditions 23Ć13..............................................
Loop Statements 23Ć17.......................................................
Summary 23Ć29..............................................................
Practice Overview 23Ć31......................................................
Practice 23 23Ć33............................................................
x
24. Processing Queries by Using Explicit Cursors 24Ć1...........................
Objectives 24Ć3.............................................................
Overview 24Ć5..............................................................
Controlling Explicit Cursors 24Ć7..............................................
Explicit Cursor Attributes 24Ć17................................................
Cursors and Records 24Ć21...................................................

Cursors with Parameters 24Ć23.................................................
Cursor FOR Loops 24Ć25......................................................
Applying the WHERE CURRENT OF Clause 24Ć27................................
Summary 24Ć29..............................................................
Practice Overview 24Ć31......................................................
Practice 24 24Ć33............................................................
25. Error Handling 25Ć1........................................................
Objectives 25Ć3.............................................................
Overview 25Ć5..............................................................
Exception Types 25Ć7........................................................
Trapping Exceptions 25Ć9....................................................
Trapping Predefined Oracle7 Server Exceptions 25Ć11............................
Trapping NonĆPredefined Oracle7 Server Exceptions 25Ć15........................
Trapping UserĆDefined Exceptions 25Ć17........................................
Error Trapping Functions 25Ć19................................................
Propagating Exceptions 25Ć21.................................................
Summary 25Ć23..............................................................
Practice Overview 25Ć25......................................................
Practice 25 25Ć27............................................................
26. Summary of PL/SQL 26Ć1...................................................
Summary 26Ć3..............................................................
Practice Overview 26Ć9......................................................
Practice 26 26Ć11............................................................
Volume 4
A Practice Solutions AĆ1.....................................................
Preface AĆ3................................................................
Practice 1 Solutions AĆ4.....................................................
Practice 2 Solutions AĆ8.....................................................
Practice 3 Solutions AĆ20.....................................................
Practice 4 Solutions AĆ29.....................................................

Practice 5 Solutions AĆ39.....................................................
Practice 6 Solutions AĆ46.....................................................
Practice 7 Solutions AĆ55.....................................................
Practice 9 Solutions AĆ59.....................................................
Practice 10 Solutions AĆ63....................................................
xi
Practice 11 Solutions AĆ68....................................................
Practice 12 Solutions AĆ82....................................................
Practice 13 Solutions AĆ88....................................................
Practice 14 Solutions AĆ97....................................................
Practice 15 Solutions AĆ105....................................................
Practice 16 Solutions AĆ109....................................................
Practice 17 Solutions AĆ116....................................................
Practice 19 Solutions AĆ154....................................................
Practice 20 Solutions AĆ155....................................................
Practice 21 Solutions AĆ158....................................................
Practice 22 Solutions AĆ163....................................................
Practice 23 Solutions AĆ170....................................................
Practice 24 Solutions AĆ177....................................................
Practice 25 Solutions AĆ186....................................................
Practice 26 Solutions AĆ192....................................................
B Table Descriptions and Data BĆ1............................................
Summit Sporting Goods Database Diagram BĆ3................................
S_CUSTOMER Table BĆ4....................................................
S_DEPT Table BĆ7..........................................................
S_EMP Table BĆ8...........................................................
S_IMAGE Table BĆ10.........................................................
S_INVENTORY Table BĆ11....................................................
S_ITEM Table BĆ16..........................................................
S_ORDTable BĆ20...........................................................

S_PRODUCT Table BĆ22.....................................................
S_REGION Table BĆ25.......................................................
S_WAREHOUSE Table BĆ26..................................................
C Using SQL*Plus to Create Reports and Manage PL/SQL Code CĆ1............
Objectives CĆ3.............................................................
Overview CĆ5..............................................................
Entering Commands in SQL*Plus CĆ7.........................................
Comparison of SQL and SQL*Plus Commands CĆ9............................
SQL*Plus SET Commands CĆ11..............................................
Creating a Report CĆ15.......................................................
Declaring and Creating PL/SQL Blocks CĆ23....................................
Entering Commands in SQL*Plus CĆ25.........................................
Passing Input and Output Values CĆ27.........................................
Debugging in SQL*Plus CĆ31.................................................
Displaying Contents of a Subprogram CĆ35.....................................
Executing Stored Subprograms CĆ37..........................................
Summary CĆ41..............................................................
Practice Overview CĆ43......................................................
xii
Practice C CĆ45.............................................................
Practice C Solutions CĆ47....................................................
D Related Products and Services DĆ1.........................................
Related Products DĆ3.......................................................
Related Services DĆ5.......................................................
Glossary
Index
Preface
Introduction to Oracle: SQL and PL/SQL Using Procedure Builderxiv
Profile
Before You Begin This Course

Before you begin this course, you should be able to use a graphical user interface
(GUI). Required prerequisites are familiarity with data processing concepts and
techniques.
HowThis Course Is Organized
Introduction to Oracle: SQL and PL/SQL Using Procedure Builder is an
instructor-led course featuring lecture and hands-on exercises. The concepts and skills
introduced are reinforced by online demonstrations and written practice sessions.
HowThis Book Is Organized
Lesson
Aim
Lesson 1: Selecting Rows In order to extract data from the database
you need to use the Structured Query
Language (SQL) SELECT command.
You will want to create SELECT
statements that you can use time and
time again. You will also see how to save
your statements for later use.
Lesson 2: Limiting Selected Rows This lesson will cover how to restrict the
rows and columns that are displayed, as
well as how to specify the order in which
the rows are presented.
Preface xv
Profile
continued
Lesson Aim
Lesson 3: Single Row Functions Functions make the basic query block
more powerful and are used to
manipulate data values. This is the first
of two lessons that explore functions.
You will focus on single row character,

number, and date functions, as well as
those functions that convert data from
one type to another, for example,
character data to numeric.
Lesson 4: Displaying Data from Multiple
Tables
This lesson will cover how to obtain data
from more than one table, using the
many different methods available.
Lesson 5: Group Functions This lesson further addresses functions.
You will focus on obtaining summary
information, such as averages, for groups
of rows. You will discuss how to group
rows in a table into smaller sets, and how
to specify search criteria for groups of
rows.
Lesson 6: Subqueries This lesson covers more advanced
features of the SELECT statement. You
can write subqueries in the WHERE
clause of another SQL statement to
obtain values based on an unknown
conditional value.
Lesson 7: Specifying Variables at
Runtime
You can create a command file
containing a WHERE clause to restrict
the rows displayed. To change the
condition each time the command file is
run, you use substitution variables.
Substitution variables can replace values

in the WHERE clause, a text string, and
even a column or a table name.
Introduction to Oracle: SQL and PL/SQL Using Procedure Builderxvi
Profile
continued
Lesson Aim
Lesson 8: Overview of Data Modeling
and Database Design
Before you build your tables, you design
your database. You examine the data
modeling process and relational database
concepts, and define normalization. You
also translate an entity relationship
model into a relational database design.
Lesson 9: Creating Tables You will create tables. You will also
build integrity constraints, which are
rules governing what can and cannot be
done with the data.
Lesson 10: Oracle Data Dictionary The Oracle data dictionary is one of the
most important components of the
Oracle7 Server. It consists of a set of
tables and views that provide a read-only
reference to the database.
Lesson 11: Manipulating Data Once your tables have been created, you
will need to add new rows, make
changes to rows in a table, or delete rows
by using data manipulation commands.
This lesson covers using SQL commands
to make changes to data. A number of
these data manipulation commands make

up a transaction, which you may either
save or delete using transaction controls.
Lesson 12: Altering Tables and
Constraints
After you create your tables, you may
need to change the table structures
because you omitted a column, your
column definition needs to be changed,
or you want to enable or disable
constraints. This lesson will demonstrate
how you can amend table structures as
well as add and remove constraints.
Preface xvii
Profile
continued
Lesson Aim
Lesson 13: Creating Sequences Many applications require the use of
unique numbers as primary key values.
You can either build code into the
application to handle this requirement or
use a sequence to generate unique
numbers. This lesson covers creating and
using sequences that crate unique
numbers.
Lesson 14: Creating Views In this lesson, you will see how views
can be used to present data to users in a
variety of ways. In addition, you will see
how integrity constraints can be
enforced, if using a view to insert,
update, or delete data.

Lesson 15: Creating Indexes If you want to improve the performance
of some queries, you should consider
creating an index. You can also use
indexes to enforce uniqueness on a
column or a collection of columns.
Lesson 16: Controlling User Access This lesson describes the Oracle7 Server
decentralized security system. Using the
commands covered in this lesson, you
can control database access to specific
objects and add new users with different
levels of access privileges. You can
provide alternative names for objects by
using the CREATE SYNONYM
command.
Introduction to Oracle: SQL and PL/SQL Using Procedure Builderxviii
Profile
continued
Lesson Aim
Lesson 17: Summary of SQL and
SQL*Plus (optional)
This lesson reviews the basic commands
covered in the course so far.
Lesson 18: Overview of PL/SQL Overview lesson of how to create and
use PL/SQL program units and
subprograms using Oracle Procedure
Builder.
Lesson 19: Basics of Procedure Builder A key feature of procedural
programming is the ability to create and
debug code quickly and easily.
Procedure Builder provides all of the

functionality necessary for you to
successfully develop and debug PL/SQL
programs. This lesson enables you to
manipulate PL/SQL code using
Procedure Builder.
Lesson 20: Modularizing Programming
with Subprograms
Modularity allows you to break your
code into manageable, well-defined
units. Each of these units in PL/SQL has
two types of subprograms called
procedures and functions. You will learn
the structure of subprograms and how to
invoke them.
Lesson 21: Developing a Simple
PL/SQL Block
Create a simple PL/SQL block after
learning the various elements that
compose a block.
Lesson 22: Interacting with Oracle Access the database and control
transactions through SQL statements in
PL/SQL.
Preface xix
Profile
continued
Lesson Aim
Lesson 23: Using Control Structures Control the flow of your PL/SQL block
by using conditional statements and
loops.
Lesson 24: Processing Queries with

Explicit Cursors
Use a multiple row SELECT statement
within PL/SQL to process many rows.
Declare and control explicit cursors,
which are used in loops, including the
cursor FOR loop.
Lesson 25: Error Handling When you execute PL/SQL code, you
may encounter errors. The error causes
the PL/SQL block to halt with an
exception. You can trap the exception
and perform actions conditionally using
exception handlers.
Lesson 26: Summary of PL/SQL
(optional)
Review the topics covered in the course.
Create a PL/SQL-based application for
manipulating and maintaining
information in your database.
Introduction to Oracle: SQL and PL/SQL Using Procedure Builderxx
Related Publications
Oracle Publications
Title
Part Number
Oracle7 Server SQL Reference, Release 7.3 A32538
SQL*Plus User’s Guide and Reference, Release 3.3 A42562–1
PL/SQL User’s Guide and Reference, Release 2.3 A32542
Oracle7 Server SQL Language Quick Reference 5421–70–1292
SQL*Plus Quick Reference, Release 3.3 A42561
Oracle Procedure Builder 1.5 Developer’s Guide A32485
Oracle7 Server Concepts Manual, Release 7.3 A32534

Oracle Press: Oracle Beginner’s Guide A31178–1
Oracle Press: Oracle Complete Reference A10197–1
Additional References
D
System Release Bulletins
D
Installation and User’s Guides
D
read.me Files
D
International Oracle User’s Group (IOUG) Articles
D
Oracle Magazine
Preface xxi
Typographic Conventions
Typographic Conventions Within Text
Convention
Object or Term Example
Uppercase Commands,
functions,
column names,
table names,
PL/SQL objects,
schemas
Use the SELECT command to view
information stored in the LAST_NAME
column of the S_EMP table.
Lowercase,
italic
File names,

syntax variables,
usernames,
passwords
where: role is the name of the role to be
created.
Initial cap Triggers and
button names
Assign a When–Validate–Item trigger to the
S_ORD block.
Press the Cancel button.
Italic Books, names of
courses and
manuals, and
emphasized
words or phrases
For further information on the subject see:
Oracle7 Server SQL Language Reference
Manual
Do not save changes to the database.
Quotation marks Lesson module
titles referenced
within a course
This subject is covered in Lesson 3, “Working
with Objects.”
Italic bold The first time a
glossary word is
referred to in a
section
The algorithm inserts the new key.
Introduction to Oracle: SQL and PL/SQL Using Procedure Builderxxii

Typographic Conventions
continued
Typographic Conventions Within Code
Convention
Object or Term Example
Uppercase Commands,
functions
SQL> SELECT userid
2 FROM s_emp;
Lowercase,
italic
Syntax variables SQL> CREATE ROLE role;
Lowercase Column names,
table names, file
names, PL/SQL
objects
. . .
OG_ACTIVATE_LAYER
(OG_GET_LAYER (’prod_pie_layer’))
. . .
SQL> SELECT last_name
2 FROM s_emp;
SQLDBA> DROP USER scott
2> IDENTIFIED BY tiger;
Bold Text that must
be entered by a
user.
SQL> SELECT userid
2 FROM s_emp;
Vertical bar Separates

alternative
syntax elements
OFF | ON
Brackets Optional items
list in syntax
[OFF | ON]
Braces Mandatory
items list in
syntax
{OFF | ON}
Underlining Default value in
syntax
{OFF | ON}
Preface xxiii
Typographic Conventions
continued
Symbols Used in This Document
Guidance relating to the subject matter, such as hints or advice.
For more information, see
a publication related to the subject matter
This icon indicates a warning relating to the subject matter. An example warning
might be “When deleting rows, word your WHERE clause carefully.”
Used for a series of instructions that must be followed in sequential order.
Introduction to Oracle: SQL and PL/SQL Using Procedure Builderxxiv
Introduction
I

×