From the Inside Flap
The Oracle PL/SQL Interactive Workbook 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 workbook teaches you about cursors, procedures, and triggers 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 experience with relational databases, 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 CTA program New York City. The student body is rather diverse, in that there are some students who have years of experience with 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.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
Exercise Answers with Detailed Discussion
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. So, 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 that you have the Lab material. The answers to these questions appear in Appendix A. There are also additional Self-Review Questions at this book's companion Web site, found at phptr/rosenzweig
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 at the companion Web site.
The chapters should be completed in sequence because PL/SQL builds itself chapter by chapter. Additionally, many of the files you create and save in earlier chapters will be required in later chapters. In the end, all of the skills you have acquired, and files you have created, will come together in Chapter 13 and 14, "Packages" and "Stored Code," where you will create a package.About The Companion Web Site
The companion Web site is located at phptr/rosenzweig
Here you will find two very important things:
Files you will need before you begin reading the workbook.
Answers to the Test Your Thinking questions.
All of the Exercises and questions are based on a sample database called STUDENT. The files required to created and install this STUDENT schema are downloadable from the Web site.
The answers to the Test Your Thinking section will also be found at the web site.
In addition to required files and "Test Your Thinking" answers, the Web site will have many other features like additional review questions, a message board, and periodically updated information about the book.
You should visit the companion Web site and download the required files before starting the Labs and Exercises.What You'll Need
There are software programs as well as knowledge requirements necessary to complete the exercise sections of the workbook.Software
Access to the WWW
Windows 95/98 or NT 4.0Oracle8
Oracle8 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 8.0.5 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).
Additionally, you should have access to and be familiar with SQL*Plus. This book was used running SQL*Plus version 8.0.5.
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. SQL*Plus is used throughout this book, since SQL*Plus comes with the Oracle Personal Edition and Enterprise Edition.SQL*PLUS
You should be familiar with using SQL*Plus to execute SQL statements (if not then refer to the other book in the Prentice Hall Interactive Oracle Series on this topic Morrison/Rishchert's Oracle Interactive Workbook: SQL). There are a few key differences between executing SQL statement 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: 1) with a semicolon (;) 2) with a backslash (/) on a line by itself or 3) 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.* FOR EXAMPLESQL> select sysdate 2 from dual 3 ;SYSDATE---------24-NOV-99SQL>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 EDIT at the SQL prompt. The default text editor will open with the contents of the SQL Buffer. You can edit the file and then exit the editor. This will cause the contents of the SQL Buffer to change. SQL*Plus commands such as SET SERVEROUTPUT ON are not captured into the SQL Buffer nor does SQL*Plus store the semicolon or the 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 subprogram, thus when you end a line with a semicolon you will not terminate the PL/SQL subprogram. You can terminate the PL/SQL subprogram by entering a period(.). This will end the block and leave the block in the SQL Buffer, but it will not execute the subprogram. You have a choice, to enter EDIT and edit the program, or execute the subprogram with a backslash (/) or an RUN. A semicolon (;) will not execute these SQL commands as it does other SQL commands.
You might 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.SQL>
If you run a script file that you have saved on your computer, you must remember to complete your program with a period(.). If you simply want to put the code into the SQL Buffer you can end the script with a backslash (/) which will execute the file.SQL> @scriptFilename.sql
The failure to end your PL/SQL block with a period (.) or a backslash (/) will prevent your block from executing.Windows 95/98 or NT 4.0
The SQL*Plus development environment is available on a number of different operating system platforms including Microsoft Windows and various flavors of UNIX. The exercises and examples in this workbook were created using Microsoft Windows NT 4.0 with service pack 3. Therefore, they are geared more for those working in
From the Back Cover
FREE Access to Interactive Oracle PL/SQL Training Web Site
- Build Oracle PL/SQL applications-now!
- No Oracle PL/SQL experience necessary!
- Covers all key Oracle PL/SQL concepts
- Real-life labs and "Test Your Thinking" Q&As
Start developing applications with Oracle PL/SQL-fast! This integrated book-and-Web learning solution teaches all of the Oracle PL/SQL skills you need, through hands-on, real-world labs, exercises, projects, and our great Web-based training site. You'll master PL/SQL syntax and structured programming, iterative control, scoping and anchored datatypes, cursors, triggers, security, tables-even sophisticated packaging and parameter passing techniques! Your free Web-based training module includes a Virtual Study Lounge where you can interact with the author, interactive Q&As, new projects, book updates, and more!
-Totally integrated with a FREE, state-of-the-art Oracle Forms learning Web site!
Every Prentice Hall Interactive Workbook is fully integrated with its own exclusive Web site, giving you all this and more:
- "Test Your Thinking" project solutions and detailed explanations
- Author's Corner: Your personal connection to this book's expert author
- Additional self-review exercises with instant feedback and explanations
- An exclusive Virtual Study Lounge where you can interact with other learners!
Just the facts! No endless, boring discussions here! You'll learn hands-on, through practical exercises, self-review questions and real-world answers. Exclusive "Test Your Thinking" projects guarantee you'll go beyond rote knowledge to really master the subject! It's an integrated learning system that's proven to work!
Dozens of exercises cover the real-world tasks that matter most!
100s of self-review questions and answers make sure you understand!
Sample exercise from this title
Sample Self-Review Questions Page from this title