About This eBook
ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturers Web site.
Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a Click here to view code image link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
Oracle PL/SQL by Example
Fifth Edition
Benjamin Rosenzweig
Elena Rakhimov
Upper Saddle River, NJ Boston Indianapolis San Francisco
New York Toronto Montreal London Munich Paris Madrid
Capetown Sydney Tokyo Singapore Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at or (800) 382-3419.
For government sales inquiries, please contact .
For questions about sales outside the U.S., please contact .
Visit us on the Web: informit.com/ph
Library of Congress Cataloging-in-Publication Data
Rosenzweig, Benjamin.
Oracle PL/SQ by example / Benjamin Rosenzweig, Elena Rakhimov.Fifth edition.
pages cm
Includes index.
ISBN 978-0-13-379678-0 (pbk. : alk. paper)ISBN 0-13-379678-7 (pbk. : alk. paper)
1. PL/SQL (Computer program language) 2. Oracle (Computer file) 3. Relational databases.
I. Rakhimov, Elena Silvestrova. II. Title.
QA76.73.P258R68 2015
005.756dc23 2014045792
Copyright 2015 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to (201) 236-3290.
ISBN-13: 978-0-13-379678-0
ISBN-10: 0-13-379678-7
Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana.
First printing, February 2015
To my parents, Rosie and Sandy Rosenzweig,
for their love and support
Benjamin Rosenzweig
To my family, for their excitement and encouragement
Elena Rakhimov
Contents
Preface
OraclePL/SQL by Example, Fifth 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, OraclePL/SQL by Example 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 Oracles PL/SQL language. The ideal readers are those with some relational database experience, with some Oracle experience, specifically with SQL, SQL*Plus, and SQL Developer, but with little or no experience with PL/SQL or with most other programming languages.
The content of this book is based primarily on the material that was taught in an Introduction to PL/SQL class at Columbia Universitys Computer Technology and Applications (CTA) program in New York City. The student body was rather diverse, in that there were some students who had years of experience with information technology (IT) and programming, but no experience with Oracle PL/SQL, and then there were 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 additional exercises available through the companion website can be used as labs 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 explaining a programming concept or a particular PL/SQL feature and then illustrate it further by means of examples. Oftentimes, as the topic is discussed more in depth, these examples would be changed to illustrate newly covered material. In addition, most of the chapters of this book have Additional Exercises sections available through the companion website. These exercises allow you to test the depth of your understanding of the new material.
The basic structure of each chapter is as follows:
Objectives
Introduction
Lab
Lab...
Summary
The Objectives section lists topics covered in the chapter. Basically a single objective corresponds to a single Lab.
The Introduction offers a short overview of the concepts and features covered in the chapter.
Each Lab covers a single objective listed in the Objectives section of the chapter. In some instances the objective is divided even further into the smaller individual topics in the Lab. Then each such topic is explained and illustrated with the help of examples and corresponding outputs. Note that as much as possible, each example is provided in its entirety so that a complete code sample is readily available.
At the end of each chapter you will find a Summary section, which provides a brief conclusion of the material discussed in the chapter. In addition, the By the Way portion will state whether a particular chapter has an Additional Exercises section available on the companion website.
About the Companion Website
The companion Website is located at informit.com/title/0133796787. Here you will find three very important things:
Files required to create and install the STUDENT schema.