PL/SQL User's Guide and Reference Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents
Go to Index
Index



Go to previous file in sequence Go to next file in sequence

Info


PL/SQL is Oracle Corporation's procedural language extension to SQL, the standard data access language for relational databases. PL/SQL offers modern software engineering features such as data encapsulation, information hiding, overloading, and exception handling, and so brings state-of-the-art programming to the Oracle Server and Toolset.

Designed to meet the practical needs of software developers, this guide explains all the concepts behind PL/SQL and illustrates every facet of the language. Good programming style is stressed throughout and supported by numerous examples. Here is all the information you need to understand PL/SQL and use it effectively to solve your information management problems.


Audience

Anyone developing applications for the Oracle Server will benefit from reading this guide. Written especially for programmers, this comprehensive treatment of PL/SQL will also be of value to systems analysts, project managers, and others interested in database applications. To use this guide effectively, you need a working knowledge of the following subjects:

You will not find installation instructions or system-specific information in this guide. For that kind of information, see the Oracle installation or user's guide for your system.


What's New in This Edition?

Release 2.3 of PL/SQL offers an array of new features to help you build better database applications. For example, now you can benefit from

For more information, see Appendix A.


How This Guide Is Organized

The PL/SQL User's Guide and Reference is divided into three parts: a user's guide, a language reference, and appendices.

User's Guide

This part introduces you to PL/SQL and shows you how to use its many features.

Chapter 1: Overview This chapter surveys the main features of PL/SQL and points out the advantages they offer. It also acquaints you with the basic concepts behind PL/SQL and the general appearance of PL/SQL programs.

Chapter 2: Fundamentals This chapter focuses on the small-scale aspects of PL/SQL. It discusses lexical units, scalar datatypes, user-defined subtypes, expressions, assignments, block structure, declarations, scope, and built-in functions.

Chapter 3: Control Structures This chapter shows you how to structure the flow of control through a PL/SQL program. It describes conditional, iterative, and sequential control. You learn how to apply simple but powerful control structures such as IF-THEN-ELSE and WHILE-LOOP.

Chapter 4: PL/SQL Tables and User-Defined Records This chapter focuses on the composite datatypes TABLE and RECORD, which can store collections of data. You learn how to reference and manipulate these collections as whole objects.

Chapter 5: Interaction with Oracle This chapter shows you how PL/SQL supports the SQL commands, functions, and operators that let you manipulate Oracle data. You also learn how to manage cursors, process transactions, and safeguard the consistency of your database.

Chapter 6: Error Handling This chapter provides an in-depth discussion of error reporting and recovery. You learn how to detect and handle errors using PL/SQL exceptions.

Chapter 7: Subprograms This chapter shows you how to write and use subprograms, which aid application development by isolating operations. It discusses procedures, functions, forward declarations, actual versus formal parameters, positional and named notation, parameter modes, parameter default values, aliasing, overloading, and recursion.

Chapter 8: Packages This chapter shows you how to bundle related PL/SQL types, objects, and subprograms into a package. Once written, your general-purpose package is compiled, then stored in an Oracle database, where its contents can be shared by many applications.

Chapter 9: Execution Environments This chapter shows you how to use PL/SQL in the SQL*Plus, Oracle Precompiler, and Oracle Call Interface (OCI) environments.

Language Reference

This part serves as a reference guide to PL/SQL commands, syntax, and semantics.

Chapter 10: Language Elements This chapter uses BNF-style syntax definitions to show how commands, parameters, and other language elements are sequenced to form PL/SQL statements. Also, it provides usage notes and short examples to help you become fluent in PL/SQL quickly.

Appendices

This part provides a survey of new features, sample programs, supplementary technical information, and a list of reserved words.

Appendix A: New Features This appendix looks at the array of new features offered by release 2.3 of PL/SQL.

Appendix B: Sample Programs This appendix provides several PL/SQL programs to guide you in writing your own. The sample programs illustrate important PL/SQL concepts and features.

Appendix C: CHAR versus VARCHAR2 Semantics This appendix explains the subtle but important semantic differences between the CHAR and VARCHAR2 base types.

Appendix D: PL/SQL Wrapper This appendix shows you how to run the PL/SQL Wrapper, a standalone utility that enables you to deliver PL/SQL applications without exposing your source code.

Appendix E: Reserved Words This appendix lists those words reserved for use by PL/SQL.


Notational Conventions

This guide uses the following notation in code examples:

< >

Angle brackets enclose the name of a syntactic element.

- -

A double hyphen begins a single-line comment, which extends to the end of a line.

/* and */

A slash-asterisk and an asterisk-slash delimit a multi-line comment, which can span multiple lines.

.

A dot separates an object name from a component name and so qualifies a reference.

...

An ellipsis shows that statements or clauses irrelevant to the discussion were left out.

UPPERCASE

Uppercase denotes PL/SQL keywords.

lowercase

Lowercase denotes user-defined items such as variables, parameters, and exceptions.

The syntax of PL/SQL is described using a simple variant of Backus-Naur Form (BNF). See "Reading Syntax Definitions" on page 10 - 3.

Terms being defined for the first time, words being emphasized, error messages, and book titles are italicized.


Sample Database Tables

Most programming examples in this guide use two sample database tables named dept and emp. Their definitions follow:

CREATE TABLE dept
    (deptno NUMBER(2) NOT NULL,
     dname  CHAR(14),
     loc    CHAR(13))
  
CREATE TABLE emp
    (empno    NUMBER(4) NOT NULL,
     ename    CHAR(10),
     job      CHAR(9),
     mgr      NUMBER(4),
     hiredate DATE,
     sal      NUMBER(7,2),
     comm     NUMBER(7,2),
     deptno   NUMBER(2))

Sample Data

Respectively, the dept and emp tables contain the following rows of data:

DEPTNO  DNAME      LOC
------- ---------- ---------
10      ACCOUNTING NEW YORK
20      RESEARCH   DALLAS
30      SALES      CHICAGO
40      OPERATIONS BOSTON
  
EMPNO ENAME   JOB          MGR  HIREDATE    SAL   COMM  DEPTNO
----- ------- --------- ------ --------- ------ ------ -------
 7369 SMITH   CLERK       7902 17-DEC-80    800             20
 7499 ALLEN   SALESMAN    7698 20-FEB-81   1600    300      30
 7521 WARD    SALESMAN    7698 22-FEB-81   1250    500      30
 7566 JONES   MANAGER     7839 02-APR-81   2975             20
 7654 MARTIN  SALESMAN    7698 28-SEP-81   1250   1400      30
 7698 BLAKE   MANAGER     7839 01-MAY-81   2850             30
 7782 CLARK   MANAGER     7839 09-JUN-81   2450             10
 7788 SCOTT   ANALYST     7566 19-APR-87   3000             20
 7839 KING    PRESIDENT        17-NOV-81   5000             10
 7844 TURNER  SALESMAN    7698 08-SEP-81   1500             30
 7876 ADAMS   CLERK       7788 23-MAY-87   1100             20
 7900 JAMES   CLERK       7698 03-DEC-81    950             30
 7902 FORD    ANALYST     7566 03-DEC-81   3000             20
 7934 MILLER  CLERK       7782 23-JAN-82   1300             10


Your Comments Are Welcome

We appreciate your comments. As we evaluate and revise our documentation, your opinions are the most important feedback we receive. At the back of our printed manuals is a Reader's Comment Form, which we encourage you to use. If the form is not available, please use the following address or fax number:

Oracle7 Server Documentation Manager
Oracle Corporation
500 Oracle Parkway
Redwood Shores, CA 94065
Fax: (415) 506-7200




Go to previous file in sequence Go to next file in sequence
Prev Next
Oracle
Copyright © 1996 Oracle Corporation.
All Rights Reserved.
Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents
Go to Index
Index