作者:empty 页数:180 出版社:empty |
Oracle PL/SQL LanguagePocket Reference
IntroductionThe Or ad ePL/SQL Language Pocket ReJ erences a quik reference guide to the PL/SQL programming language, whichprov des procedural exten st on stu the SQL relational data-base language and a range of Oracle development toolswher ca pack agr.prg am, orunctonssuppuredunlyfurapameuarveaonoftheOraded at base eg.Or aeD a abase iig.we in dba eths in the tex.The purp use of this pocket reference is to help PL/SQL usersfind the syntax of specific language elements.It is not a self-contained userguide, bas acknowledge of the PL/SQL pro-gramming language is assumed.For more information.seethe full owing OReilly bao ks:Oracle PL/SQLPragramtnig, Four hE dht n, by StevenFeuerstein with Bill PribylL earring Or adl ePL/SQL.by Bill Pribyl with Steven FeuersteinOracle PL/SQL BestPractices, Second Edition, by StevenFeuersteinOracle in aN us hell, by Rick Greenwald and David CKreinesAcknowledgmentsWe are grateful to all those who helped in the preparation ofthis book.In particular, thanks to Bryn Llewellyn for his
input on this latest revision as wll as the third edition.Thanks as well to frst-edtionrevewersEneJGivler andStephen Nelson and to second-and third-edition reviewerJonathan Gen nick.In addition, we appreciate all the goodwork by the O'Ret lly crew in editing and producing thisbook.ConventionsUPPERCASE indie ate sPL/SQL keywords, as well ascertainidentifiers used by Oracle Corporation as built-in functionand package names.Italic indicates fle names and directories, as well as the firstuse of a term.Constant width is used for code examples, lter as, andidentifiers.Constant width bold indicates userinput in examples show-ingan interactionI] enclose optional items in syntax descriptions.fen clus east of items in syntax descript a ons, you mustchoose one item from the list.|separates bracketed ls tiems in syntax descriptions.PL/SQL Language FundamentalsThis see tion summarizes the fundamental components of thePL/SQL language:characters, identifiers, literals.delimiters,use of comments and pragmas, and construe tion of state-ments and blocks.PL/SQL Character SetThe PL/SQL language is construe ted from letters, digits,symbols, and whitespace, as defined in the following table:2|Or adl ePL/SQL Language Pocket ReferenceTypehara dersLrt tersA-Z.a-ZDig is0-9Symb akWiil espa ueopac etat, new it e, a i agere lum_Charactersaregroupedtogetherintofourlexicalunits:iden-tif ers, literals, de liters, and comments.IdentifiersIdenti hers are names for PL/SQL objects such as constants,var ables, exceptions, procedures, cursors, and reservedwords.Identifiers have the following characteristics:·Can be u pro 30 characters in length·Can not include whitespace(space, tab, car age return!·Must start with a letter·Can include a dollar sign(s) , an underscore() ) , and apound sign(m)*Are nor case-sensitiveUsing PL/SQL's reserved words as identi hers in your pro-grams is not a good idea and can result in comp lation orruntime errors that are difficult to troubleshootTIPEarle rcd sunsoft his ba ok included a list of reservedwords.However, Oracle Database l1g Release 1 hasnot be used as procedure names or variable names Con-sl:VSRESERVED_WORDSforthefullitofunsup-pnr ted identifiers.and avn id using these as program orvar able namesPL/SQL Language Fundament as| 3
If you enclose an i denn fier within double quotes, all but thefirst of these rules are ignored.For example, the followingdeclaration is vald:DEc iaf.Boolean, Numeric, and String LiteralsLiterals are specifi e values not represented by identifer s.Forexample, TRUE, 3.14159, 6.63E-34, 'Moby Dick, and NULLare all literals of type Boolean, number, or string.There areno complex datatype literals as their values are internal rep-resentations, complex types receive values through dire etassignment or via constructors, Unlike the rest of PL/SQL,literals are ease-sensitive.Ta embed single quotes within astring literal.place two single quotes nex s to eachother.Starting with Oracle Database 10g.you can defe your ownstraigh r single quote) to designate the programmer-dehne ddelimiter for your string literal Term ui nate the literal strngwith the programmer-dened delimiter followed by a trailingsngl e quote-for example, o'!myst rig!'NCHAR andNVARCHAR delimiters are preceded by the letters nq, as innq'on char string*'-This technique can simplify your codewhen consecutive single quo ces appear within a string, suchas the literals in a SQL statement lf you define your delimiterwth one of the four bracken g characters([{s you mustuse the rg hth and vers ton of the bracketing character as theclosing delimiter.For example.q'[must be closed with]You may achieve improvements in runtime performance bymaking explicit the datatype of numeric it erals.You can doso by including or excluding a decimal point or by using aOracle Database 10gintruduced several special named
Introduction
Acknowledgments
Conventions
PL/SQL Language Fundamentals
PL/SQL Character Set
Second Edition
Third Ed in ion
Four rh Edition.
Pocket Rr ferences enes
Contents
rade mat ks.Where those design atio
Identifiers
Boolean, Numeric, and String Liter as
Numeric Literals
Date timeInterval Literals
Delimiters
Comments
Pragmas
Statements
Block Structure
Variables and Program Data
Scalar Datatypes
LOB Datatypes
Implicit Datatype Conversions
NULLs in PL/SQL
Declaring Variables
Anchored Declarations
Programmer-Defined Subtypes
2234
Condtion al and Sequential Control
Conditional Control Statements
Sequential Control Statements
Loops
Simple Loop
Numeric FOR Loop
Cursor FOR Loop
WHILE Loop
REPEAT UNTIL Loop Emulation
EXIT Statement
CONTINUE Statement(OradleDatabase11g)
Loop Labels
Database Interaction
Sequences in PLSQL
Transaction Management
Autonomous Transactions
Cursors in P/SQL
Explict Cursors
Implicit Cursors
Dynamic Cursors
DBMS_SQL
50L Injection and Bind Variables
Cursor Variables
Cursor Expressions
Exception Handling
Declaring Exceptions
Raising Exceptions
Scope
Propagation
iv|Cent ents
Records in PL/SQL
Declaring Records
Referencing Fields of Records
Assigning Records
Records and DML
Nested Records
Collections in PL/SQL
Declaring a Collection
Initializing a Collection
Adding and Removing Elements
Nested Table Functions
Collection Methods
Collections and Privileges
Nested Collections
Bulk Binds
Built-in Functions and Packages
Buit-in Functions
Built n RegularExpression Functions
Builtin Packages
Stored Procedures and Functions
Procedures
Functions
Parameters
Local Programs
Program Overloading
Forward Deda rations
Table Functions
Function Result Cache
Privileges and Stored PL/SQL
Contents lv
Creating Triggers
Trigger Predicates
DML Events
Compound DML Triggers
DDL Events
Database Events
Packages
Package Structure
Referencing Package Elements
Package Data
SERIALLY_REUSABLE Pragma
Package Initialization
Call n gPL/SQL Functions in5QL
Calling a Function
Calling Packaged Functions in SQL
Column/Function Name Precedence
Object-Oriented Features
Object Types
Type Inheritance
Methods
Methods in Subtypes
Manipula ing Objects in PL/SQL and SQL
Up casting and Down casting
Chang ng Object Types
Comp iation
Comp ling Stored PL/SOL Programs
Conditional Compilation
Compiler Wa mings
Optimizing Compiler
Performing Native Compilation of PL/SQL
w|Can tents
Java Language Integration
Example
Publishing Java to PL/SQL
Data Dictionary
Index
Content|v
Oracle PL/SQL Language
Pocket Reference