Home > Store

Oracle PL/SQL Interactive Workbook, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

Oracle PL/SQL Interactive Workbook, 2nd Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • NEW - Fully updated and expanded to reflect Oracle 9i's version of PL/SQL.
    • Helps students rapidly master the most valuable features incorporated in the latest version of Oracle PL/SQL.

  • Uniquely effective hands-on workbook format—Gives students hands-on practice through real-world exercises, labs, and projects.
    • Helps students master Oracle PL/SQL more rapidly and retain more of what they learn.

  • Comprehensive coverage of Oracle PL/SQL fundamentals—Covers syntax, program control, scoping, datatypes, cursors, triggers, security, tables, packaging, exceptions, cursors, collections, records, and more.
    • Gives students a single resource for learning all the Oracle PL/SQL skills they are likely to need.

  • Web-based training module—Supports the book with an extensive, integrated set of online features.
    • Gives students access to constant updates on even more learning resources.

  • By two of the world's leading database educators—Authored by Ben Rosenzweig and Elena Silvestrova, faculty members in the Database Application Development and Design track at Columbia University's School of Continuing Education.
    • Lets students benefit from authoritative coverage by leading experts in both database technology and database instruction.

  • Virtual Study Lounge—Provides an online venue where students can interact with each other.
    • Helps students resolve their own questions and learn from each other.

Description

  • Copyright 2003
  • Dimensions: 7" x 9-1/4"
  • Pages: 688
  • Edition: 2nd
  • Book
  • ISBN-10: 0-13-047320-0
  • ISBN-13: 978-0-13-047320-2

Learn PL/SQL hands-on, through practical exercises, self-review questions and real-world answers. This book teaches all the Oracle PL/SQL skills you need, through hands-on, real-world labs, exercises, projects, and our great Web-based training site! Coverage includes every key Oracle PL/SQL concept, including: the basics of structured programming; PL/SQL structure and syntax; iterative control; scoping and anchored datatypes; SQL within PL/SQL; for update cursors and subprograms; stored code, triggers, security, tables, even advanced-level package and parameter passing techniques. A free Web-based training module includes a Virtual Study Lounge where readers can interact with the author. As Oracle's premier tool for building store procedures, PL/SQL uniquely supplements the standard relational database language, SQL, with the features needed to build real-world applications. Oracle Developers typically learn SQL before venturing in to Oracle's PL/SQL. SQL is the foundation Language on which PL/SQL is build.

Extras

Solutions

To aid your work with Oracle PL/SQL Interactive Workbook, 2/e, we are providing online the solutions to the Test Your Thinking exercises from each chapter.

Select a Chapter for Test Your Thinking Solutions

  1. Programming Concepts
  2. PLSQL Concepts
  3. General Programming Language Fundamentals
  4. SQL in PLSQL
  5. Conditional Control: IF Statements
  6. Conditional Control: CASE Statements
  7. Error Handling and Built-In Exceptions
  8. Iterative Control
  9. Introduction to Cursors
  10. Exceptions
  11. Exceptions: Advanced Concepts
  12. Procedures
  13. Functions
  14. Packages
  15. Advanced Cursors
  16. Stored Code
  17. Triggers
  18. Collections
  19. Records

Sample Content

Online Sample Chapters

Oracle PL/SQL Programming Concepts

Programming Language Fundamentals in PL/SQL

Table of Contents



Acknowledgments.


About the Authors.


Introduction.


1. Programming Concepts.

LAB 1.1 The Nature of a Computer Program and Programming Languages. LAB 1.2 Good Programming Practices. Chapter 1 Test Your Thinking.



2. PL/SQL Concepts.

LAB 2.1 PL/SQL in Client-Server Architecture. LAB 2.2 PL/SQL in SQL*Plus. Chapter 2 Test Your Thinking.



3. General Programming Language Fundamentals.

LAB 3.1 PL/SQL Programming Fundamentals. Nested Blocks, and Labels. Chapter 3 Test Your Thinking.



4. SQL in PL/SQL.

LAB 4.1 Making Use of DML in PL/SQL. LAB 4.2 Making Use of SAVEPOINT. Chapter 4 Test Your Thinking.



5. Conditional Control: IF Statements.

LAB 5.1 IF Statements. LAB 5.2 ELSIF Statements. LAB 5.3 Nested IF Statements. Chapter 5 Test Your Thinking.



6. Conditional Control: Case Statements.

LAB 6.1 CASE Statements. LAB 6.2 CASE Expressions. LAB 6.3 NULLIF and COALESCE Functions. Chapter 6 Test Your Thinking.



7. Error Handling and Built-In Exceptions.

LAB 7.1 Handling Errors. LAB 7.2 Built-In Exceptions. Chapter 7 Test Your Thinking.



8. Iterative Control.

LAB 8.1 Simple Loops. LAB 8.2 WHILE Loops. LAB 8.3 Numeric FOR Loops. LAB 8.4 Nested Loops. Chapter 8 Test Your Thinking.



9. Introduction to Cursors.

LAB 9.1 Cursor Manipulation. LAB 9.2 Using Cursor FOR Loops and Nesting Cursors. Chapter 9 Test Your Thinking.



10. Exceptions.

LAB 10.1 Exception Scope. LAB 10.2 User-Defined Exceptions. LAB 10.3 Exception Propagation. Chapter 10 Test Your Thinking.



11. Exceptions: Advanced Concepts.

LAB 11.1 RAISE_APPLICATION_ERROR. LAB 11.2 EXCEPTION_INIT Pragma. LAB 11.3 SQLCODE and SQLERRM. Chapter 11 Test Your Thinking.



12. Procedures.

LAB 12.1 Creating Procedures. LAB 12.2 Passing Parameters In and Out of Procedures. Chapter 12 Test Your Thinking.



13. Functions.

LAB 13.1 Creating and Using Functions. Chapter 13 Test Your Thinking.



14. Packages.

LAB 14.1 The Benefits of Utilizing Packages. Chapter 14 Test Your Thinking.



15. Advanced Cursors.

LAB 15.1 Using Parameters with Cursors and FOR UPDATE Cursors. LAB 15.2 Cursor Variables. Chapter 15 Test Your Thinking.



16. Stored Code.

LAB 16.1 Gathering Stored Code Information. Chapter 16 Test Your Thinking.



17. Triggers.

LAB 17.1 What Triggers Are. LAB 17.2 Types of Triggers. LAB 17.3 Mutating Table Issues. Chapter 17 Test Your Thinking.



18. Collections.

LAB 18.1 PL/SQL Tables. LAB 18.2 Varrays. LAB 18.3 Multilevel Collections. Chapter 18 Test Your Thinking.



19. Records.

LAB 19.1 Records. LAB 19.2 Nested Records. LAB 19.3 Collections of Records. Chapter 19 Test Your Thinking.



Appendix A. Answers to Self-Review Questions.


Appendix B. PL/SQL Formatting Guide.


Appendix C. Student Database Schema.


Appendix D. Answers to Test Your Thinking Sections.


Appendix E. Oracle 9i SQL New Features.


Index.

Preface

Introduction

The Oracle PL/SQL Interactive Workbook, 2nd edition, presents the Oracle PL/SQL programming language in a unique and highly effective format. It challenges you to learn Oracle PL/SQL by using it rather than by simply reading about it.

Just as a grammar workbook would teach you about nouns and verbs by first showing you examples and then asking you to write sentences, the Oracle PL/SQL Interactive Workbook teaches you about cursors, loops, procedures, triggers, and so on by first showing you examples and then asking you to create these objects yourself.

Who This Book Is For

This book is intended for anyone who needs a quick but detailed introduction to programming with Oracle's PL/SQL language. The ideal readers are those with some relational database experience, with some Oracle experience, specifically with SQL and SQL*Plus, but with little or no experience with PL/SQL or with most other programming languages.

The content of this book is based on the material that is taught in an Introduction to PL/SQL class at Columbia University's Computer Technology and Applications (CTA) program in New York City. The student body is rather diverse, in that there are some students who have years of experience with information technology (IT) and programming, but no experience with Oracle PL/SQL, and then there are those with absolutely no experience in IT or programming. The content of the book, like the class, is balanced to meet the needs of both extremes. The exercises in this book can be used as lab and homework assignments to accompany the lectures in such a PL/SQL course.

How This Book Is Organized

The intent of this workbook is to teach you about Oracle PL/SQL by presenting you with a series of challenges followed by detailed solutions to those challenges. The basic structure of each chapter is as follows:

Chapter    Lab          Exercises          Exercise Answers (with detailed discussion)          Self-Review Questions    Lab . . .    Test Your Thinking Questions

Each chapter contains interactive labs that introduce topics about Oracle PL/SQL. The topics are discussed briefly and then explored though exercises, which are the heart of each lab.

Each exercise consists of a series of steps that you will follow to perform a specific task, along with questions that are designed to help you discover the important things about PL/SQL programming on your own. The answers to these questions are given at the end of the Exercises, along with more in-depth discussion of the concepts explored.

The exercises are not meant to be closed-book quizzes to test your knowledge. On the contrary, they are intended to act as your guide and walk you through a task. You are encouraged to flip back and forth from the exercise question section to the exercise answer section so that, if need be, you can read the answers and discussions as you go along.

At the end of each lab is a series of multiple-choice self-review questions. These are meant to be closed-book quizzes to test how well you understood the lab material. The answers to these questions appear in Appendix A.

Finally, at the end of each chapter you will find a Test Your Thinking section, which consists of a series of projects designed to solidify all of the skills you have learned in the chapter. If you have successfully completed all of the labs in the chapter, you should be able to tackle these projects with few problems. You will find guidance and/or solutions to these in Appendix D and at the companion Web site.

About The Companion Web Site

The companion Web site is located at

http://www.phptr.com/rosenzweig2e/

Here you will find two very important things:

  • Files you will need before you begin reading the workbook: all of the exercises and questions are based on a sample database called STUDENT. The files required to create and install the STUDENT schema are downloadable from the Web site.
  • Answers to the Test Your Thinking questions.

In addition to required files and Test Your Thinking answers, the Web site will have many other features, like message board and periodically updated information about the book. There may also be some additional PL/SQL assignments without answers that can be used for graded homework.

You should visit the companion Web site, download the student schema, and install it in your database.

What You Will Need

There are software programs as well as knowledge requirements necessary to complete the exercise sections of the workbook. Note that some features covered throughout the workbook are applicable to Oracle 9i only. However, you will be able to complete a great majority of the exercise sections by using the following products:

Software

  • Oracle 7.3.4 or higher
  • SQL*Plus 3.3 or higher
  • Access to the Internet
  • Windows 95/98/2000 or NT 4.0

Oracle 9i

Oracle 9i is Oracle's RDBMS and its flagship product. You can use either Oracle Personal Edition or Oracle Enterprise Edition. If you use Oracle Enterprise Edition, this can be running on a remote server or locally on your own machine. Oracle 9.0.1.1.1 Enterprise Edition running locally was used to create the exercises for this book, but subsequent versions should be compatible (the Web site will also have scripts to create a database that will function for Oracle 7.3 and above, although features specified as Oracle 9i will not run in versions below Oracle 9).

Additionally, you should have access to and be familiar with SQL*Plus. This book was used running SQL*Plus version 9.0.1.0.1.

You have a number of options for how to edit and run scripts from SQL*Plus. There are also many third-party programs to edit and debug PL/SQL code. SQL*Plus is used throughout this book, since SQL*Plus comes with the Oracle Personal Edition and Enterprise Edition 9.0.1.0.1.

Using SQL*Plus

You should be familiar with using SQL*Plus to execute SQL statements (if not, then refer to another book in the Prentice Hall Interactive Oracle Series on this topic, Morrison/Rishchert's Oracle SQL Interactive Workbook, 2nd ed., 2004). There are a few key differences between executing SQL statements in SQL*Plus and executing PL/SQL statements in SQL*Plus. You will be introduced to these differences so that you can work with the exercises in this book.

You can end an SQL Command in SQL*Plus in one of three ways:

  • with a semicolon (;)
  • with a forward slash (/) on a line by itself
  • with a blank line

The semicolon (;) tells SQL*Plus that you want to run the command that you have just entered. You type the semicolon at the end of the SELECT statement and then press return. SQL*Plus will process what is in the SQL Buffer (described next).

n FOR EXAMPLESQL> SELECT sysdate 2 FROM dual 3 ;SYSDATE---------28-JUL-02SQL>

The SQL Buffer

SQL*Plus will store the SQL command or PL/SQL block that you have most recently entered in an area of memory known as the SQL Buffer. The SQL Buffer will remain unchanged until you enter a new command or exit your SQL*Plus session. You can easily edit the contents of the SQL Buffer by typing the EDIT command at the SQL prompt. The default text editor will open with the contents of the SQL Buffer. You can edit and save the file and then exit the editor. This will cause the contents of the SQL Buffer to change to your last saved version.

SQL*Plus commands such as SET SERVEROUTPUT ON are not captured into the SQL Buffer, nor does SQL*Plus store the semicolon or the forward slash you type to execute a command in the SQL buffer.

When you create stored procedures, functions, or packages, you begin with the CREATE command. When you begin a PL/SQL block, you start by entering the word DECLARE or BEGIN. Typing either BEGIN, DECLARE, or CREATE will put the SQL*Plus session into PL/SQL mode.

Running PL/SQL Blocks in SQL*Plus

Once you are in PL/SQL mode, you will not be able to end the block in the same manner that you ended a SQL block. The semicolon (;) can be used multiple times in a single PL/SQL block; thus when you end a line with a semicolon you will not terminate the block. You can terminate the PL/SQL block in the SQL Buffer by entering a period (.). This will end the block and leave the block in the SQL Buffer, but it will not execute it. At this point you have a choice of typing the EDIT command to edit the block or executing it with a forward slash (/) or a SQL*Plus command RUN.

n FOR EXAMPLE

You may enter and execute a PL/SQL subprogram as follows:

SQL> BEGIN 2 DBMS_OUTPUT.PUT_LINE ('This is a PL/SQL Block'); 3 END; 4 .SQL> /This is a PL/SQL BlockPL/SQL procedure successfully completed.

If want to run a script file at a later date, you must remember to terminate it with a period (.) and/or forward slash (/) before saving it on your computer. If you simply want to put the code into the SQL Buffer and then execute it, you can end the script with a forward slash (/).

You should terminate PL/SQL blocks stored in the script file with the period if you want to put the code in the SQL Buffer. You should end the script with forward slash (/) if you want the PL/SQL code in the file to execute.

The failure to end your PL/SQL block with a period (.) and/or a forward slash (/) will prevent your block from executing.

About The Sample Schema

The STUDENT schema contains tables and other objects meant to keep information about a registration and enrollment system for a fictitious university. There are ten tables in the system that store data about students, courses, instructors, and so on. In addition to storing contact information (addresses and telephone numbers) for students and instructors, and descriptive information about courses (costs and prerequisites), the schema also keeps track of the sections for particular courses, and the sections in which students have enrolled.

The SECTION is one of the most important tables in the schema because it stores data about the individual sections that have been created for each course. Each section record also stores information about where and when the section will meet and which instructor will teach the section. The section table is related to the COURSE and INSTRUCTOR tables.

The ENROLLMENT table is equally important because it keeps track of which students have enrolled in which sections. Each enrollment record also stores information about the student's grade and enrollment date. The enrollment table is related to the STUDENT and SECTION tables.

The schema also has a number of other tables that manage grading for each student in each section.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020