[1]Oracle DatabasePL/SQL Language Reference11g Release 2 (11.2)E25519-13December 2014

Oracle Database PL/SQL Language Reference, 11g Release 2 (11.2)E25519-13Copyright 1996, 2014, Oracle and/or its affiliates. All rights reserved.Primary Author: Sheila MooreContributing Author: Eric BeldenContributors: D. Alpern, E. Belden, S. Agrawal, H. Baer, S. Castledine, T. Chang, B. Cheng, R. Dani, R.Decker, C. Iyer, A. Kruglikov, S. Kotsovolos, N. Le, W. Li, B. Llewellyn, V. Moore, T. Raney, K. Rich, C.Wetherell, G. Viswanathan, M. YangThis software and related documentation are provided under a license agreement containing restrictions onuse and disclosure and are protected by intellectual property laws. Except as expressly permitted in yourlicense agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license,transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverseengineering, disassembly, or decompilation of this software, unless required by law for interoperability, isprohibited.The information contained herein is subject to change without notice and is not warranted to be error-free. Ifyou find any errors, please report them to us in writing.If this is software or related documentation that is delivered to the U.S. Government or anyone licensing iton behalf of the U.S. Government, then the following notice is applicable:U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,any programs installed on the hardware, and/or documentation, delivered to U.S. Government end usersare "commercial computer software" pursuant to the applicable Federal Acquisition Regulation andagency-specific supplemental regulations. As such, use, duplication, disclosure, modification, andadaptation of the programs, including any operating system, integrated software, any programs installed onthe hardware, and/or documentation, shall be subject to license terms and license restrictions applicable tothe programs. No other rights are granted to the U.S. Government.This software or hardware is developed for general use in a variety of information managementapplications. It is not developed or intended for use in any inherently dangerous applications, includingapplications that may create a risk of personal injury. If you use this software or hardware in dangerousapplications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and othermeasures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damagescaused by use of this software or hardware in dangerous applications.Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks oftheir respective owners.Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarksare used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD,Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of AdvancedMicro Devices. UNIX is a registered trademark of The Open Group.This software or hardware and documentation may provide access to or information about content,products, and services from third parties. Oracle Corporation and its affiliates are not responsible for andexpressly disclaim all warranties of any kind with respect to third-party content, products, and servicesunless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and itsaffiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use ofthird-party content, products, or services, except as set forth in an applicable agreement between you andOracle.

ContentsPreface . xxviiAudience. xxviiDocumentation Accessibility . xxviiRelated Documents . xxviiiConventions . xxviiiSyntax Descriptions. xxviiiWhat's New in PL/SQL?. xxixPL/SQL Feature for Oracle Database 11g Release 2 ( Features for Oracle Database 11g Release 2.PL/SQL Features for Oracle Database 11g Release 1.xxixxxixxxxi1 Overview of PL/SQLAdvantages of PL/SQL .Tight Integration with SQL.High Performance .High Productivity .Portability .Scalability .Manageability .Support for Object-Oriented Programming .Support for Developing Web Applications.Support for Developing Server Pages .Main Features of PL/SQL.Error Handling .Blocks .Variables and Constants.Subprograms.Packages .Triggers.Input and Output .Data Abstraction.Cursors .Composite Variables.%ROWTYPE Attribute -61-61-71-71-71-8v

%TYPE Attribute. 1-8Abstract Data Types . 1-8Control Statements. 1-8Conditional Compilation . 1-9Processing a Query Result Set One Row at a Time . 1-9Architecture of PL/SQL . 1-10PL/SQL Engine . 1-10PL/SQL Units and Compilation Parameters . 1-102 PL/SQL Language FundamentalsCharacter Sets. 2-1Database Character Set. 2-1National Character Set. 2-3Lexical Units . 2-3Delimiters . 2-3Identifiers . 2-4Reserved Words and Keywords . 2-5Predefined Identifiers. 2-5User-Defined Identifiers . 2-5Literals . 2-8Comments . 2-10Single-Line Comments . 2-10Multiline Comments. 2-10Whitespace Characters Between Lexical Units. 2-11Declarations. 2-12Variable Declarations. 2-12Constant Declarations . 2-13Initial Values of Variables and Constants. 2-13NOT NULL Constraint. 2-14%TYPE Attribute . 2-15References to Identifiers . 2-16Scope and Visibility of Identifiers . 2-17Assigning Values to Variables . 2-21Assigning Values to Variables with the Assignment Statement. 2-21Assigning Values to Variables with the SELECT INTO Statement . 2-22Assigning Values to Variables as Parameters of a Subprogram . 2-23Assigning Values to BOOLEAN Variables. 2-23Expressions . 2-24Concatenation Operator . 2-24Operator Precedence. 2-25Logical Operators . 2-2