Oracle PL/SQL Programming

Oracle PL/SQL Programming

4.9 10
by Steven Feuerstein, Bill Pribyl
     
 

View All Available Formats & Editions

Considered the best Oracle PL/SQL programming guide by the Oracle community, this definitive guide is precisely what you need to make the most of Oracle’s powerful procedural language. The sixth edition describes the features and capabilities of PL/SQL up through Oracle Database 12c Release 1.

Hundreds of thousands of PL/SQL developers have benefited

Overview

Considered the best Oracle PL/SQL programming guide by the Oracle community, this definitive guide is precisely what you need to make the most of Oracle’s powerful procedural language. The sixth edition describes the features and capabilities of PL/SQL up through Oracle Database 12c Release 1.

Hundreds of thousands of PL/SQL developers have benefited from this book over the last twenty years; this edition continues that tradition. With extensive code examples and a lively sense of humor, this book explains language fundamentals, explores advanced coding techniques, and offers best practices to help you solve real-world problems.

  • Get PL/SQL programs up and running quickly, with clear instructions for executing, tracing, testing, debugging, and managing code
  • Understand new 12.1 features, including the ACCESSIBLE_BY clause, WITH FUNCTION and UDF pragma, BEQUEATH CURRENT_USER for views, and new conditional compilation directives
  • Take advantage of extensive code samples, from easy-to-follow examples to reusable packaged utilities
  • Optimize PL/SQL performance with features like the function result cache and Oracle utilities such as PL/Scope and the PL/SQL hierarchical profiler
  • Build modular, easy-to-maintain PL/SQL applications using packages, procedures, functions, and triggers

Editorial Reviews


Fatbrain Review

Devoted entirely to the PL/SQL (Procedural Language extension to SQL), this second edition of Oracle PL/SQL Programming updates the first edition for Oracle8, and includes chapters on new PL/SQL object features (object types, collections, object views, and external procedures). The first three chapters of the book explain what it means to program in PL/SQL, and then walk you through the main features of the language, programming habits, and effective coding style. It then moves on to basic PL/SQL programming components such as variables, cursors, conditional and sequential control statements, loops, exception handlers, PL/SQL records, and PL/SQL tables. Part three of the book covers built-in functions such as character, date, numeric, LOB, and conversion functions that can be put to use immediately in your applications. Moving forward, you will learn how to build procedures, functions, and packages correctly. Chapters 18 through 21 give an in-depth coverage of the new features of Oracle8. Learn about object types, nested tables and VARRAYs, object views, and external procedures. Armed with a summary of helpful tips for effective PL/SQL programming in the real world, part six of the book shows you how to manage your PL/SQL code and debug, tune, and trace the execution of your programs. The text contains numerous examples to guide you as to how, when, and where to apply programming constructs most effectively. Appendices A through C contain a summary of contents on the companion disk, how to call stored procedures from PL/SQL Version 1.1, and how to call Oracle's built-in packages.
Booknews
New edition which adds chapters describing PL/SQL in terms of object features and tuning, and includes expanded discussions of debugging and tracing execution. Twenty-six chapters discuss topics including programming, language elements, built-in functions, modular code, and new PL/SQL8 features. The included disk contains the Oracle PL/SQL programming utilities guide which offers approximately 100 files of source code and documentation. Annotation c. by Book News, Inc., Portland, Or.

Product Details

ISBN-13:
9781449324452
Publisher:
O'Reilly Media, Incorporated
Publication date:
02/17/2014
Edition description:
Sixth Edition
Pages:
1392
Sales rank:
296,386
Product dimensions:
7.00(w) x 9.20(h) x 2.50(d)

Related Subjects

Read an Excerpt


From Chapter: Variables and Program Data

...The LONG datatype

A variable declared LONG can store variable-length strings of up to 32760 bytes--this is actually seven fewer bytes than allowed in VARCHAR2 type variables! The LONG datatype for PL/SQL variables is quite different from the LONG datatype for columns in the Oracle Server. The LONG datatype in Oracle7 can store character strings of up to two gigabytes or 231-1 bytes; this large size makes the LONG column a possible repository of mulitmedia information, such as graphics images.

As a result of these maximum length differences, you can always insert a PL/SQL LONG variable value into a LONG database column, but you cannot select a LONG database value larger than 32760 bytes into a PL/SQL LONG variable.

In the Oracle database, there are many restrictions on how the LONG column can be used in a SQL statement; for example:

  • A tale may not contain more than one single LONG column.

  • Yoiu may not use the LONG column in a GROUP BY, ORDER BY, WHERE, or CONNECT BY clause.

  • You may not apply character functions (such as SUBSTR, INSTR, or LENGTH), to the LONG column.

PL/SQL LONG variables are free of these restrictions. In your PL/SQL code you can use a variable declared LONG just as you would a variable declared VARCHAR2. You can apply character functions to the variable. You can use it in the WHERE clause of a SELECT or UPDATE statement. This all makes sense given that, at least from the standpoint of the maximum size of the variables, there is really little difference between VARCHAR2 and LONG in PL/SQL.

Given the fact that aVARCHAR2 variable actually has a higher maximum length than the LONG and has no restrictions attached to it, I recommend that you always use the VARCHAR2 datatype in PL/SQL programs. LONGs have a place in the RDBMS, but that role is not duplicated in PL/SQL. This makes some sense since you will very rarely want to manipulate truly enormous strings within your program using such functions as SUBSTR or LENGTH or INSTR.

The RAW datatype

The RAW datatype is used to store binary data or other kinds of raw data, such as a digitized picture or image. A RAW variable has the same maximum length as VARCHAR2 (32767 bytes), which must also be specified when the variable is declared. The difference between RAW and VARCHAR2 is that PL/SQL will not try to interpret raw data. Within the Oracle RDBMS this means that Oracle will not perform character set conversions on RAW data when it is moved from one system (based, for example, on 7-bit ASCII) to another system.

Once again, there is an inconsistency between the PL/SQL maximum length for a RAW variable (32767) and the RDBMS maximum length (255). As a result, you cannot insert more than 255 bytes of your PL/SQL RAW variable's value into a database column. You can, on the other hand, insert the full value of a PL/SQL RAW variable into a column with type LONG RAW, which is a two-gigabyte container for raw data in the database.

The LONG RAW datatype

The LONG RAW datatype stores raw data of up to 32760 bytes and is just like the LONG datatype excerpt that the data in a LONG RAW variable is not interpreted by PL/SQL.

Given the fact that a RAW variable actually has a higher maximum length than the LONG RAW and has no restrictions attached to it, I recommended that you always use the RAW datatype in PL/SQL programs. LONG RAWs have a place in the RDBMS, but that role is not duplicated in PL/SQL.

The ROWID datatype

In the Oracle RDBMS, ROWID is a pseudocolumn that is part of every table you create. the rowid is an internally generated and maintained binary value which identifies a row of data in your table. It is called a pseudocolumn because a SQL statement includes it in places where you would normally use a column. However, it is not a column that you create for the table. Instead, the RDBMS generates the rowid for each row as it is inserted into the database. The information in the rowid provides the exact physical location of the row in the database. You cannot change the value of a rowid.

You can use the ROWID datatype to store rowids from the database in your PL/SQL program. You can SELECT or FETCH the rowid for a row into a ROWID variable. To manipulate rowids in Oracle8, you will want to use the built-in package, DBMS_ROWID (see Appendix C, Built-In Packages). In Oracle7, you will use the ROWIDTOCHAR function to convert the rowid to a fixed-length string and then perform operations against that string.

In Oracle7, for format of the fixed-length rowid is as follows:

BBBBBBB.RRRR.FFFFF

Components of this format have the following meanings:

BBBBBBB

The block in the database file

RRRR

The row in the clock (where the first row is zero, not one)

FFFFF

The database file

All these numbers are hexadecimal; the database file is a number which you would then use to look up the actual name of the database file through the data dictionary.

In Oracle8, rowid have been "extended" to support partitioned tables and indexes. The new, extended rowids include a data object number, identifying the database segment. Any schema object found in the same segment, such as a cluster of tables, will have the same object number. In Oracle8, then, a rowid contains the following information:

  • The data object number

  • The data file (where the first file is 1)

  • The data block within the data file

  • The row in the data block (where the first row is 0)

Oracle8 provides functions in the DBMS_ROWID package to convert between the new formats of rowids...

Meet the Author

Steven Feuerstein is considered to be one of the world's leading experts on the Oracle PL/SQL language, having written ten books on PL/SQL, including Oracle PL/SQL Programming and Oracle PL/SQL Best Practices (all published by O'Reilly Media). He has also published his first book for kids: http://stevenfeuerstein.com/vivianvultur​e. Steven has been developing software since 1980, spent five years with Oracle (1987-1992), and served as PL/SQL Evangelist for Quest Software (and then Dell) from January 2001 to February 2014. He is an Oracle ACE Director and writes regularly for Oracle Magazine, which named him the PL/SQL Developer of the Year in both 2002 and 2006. He is also the first recipient of ODTUG's Lifetime Achievement Award (2009). Steven's latest initiative is the PL/SQL Challenge (http://www.plsqlchallenge.com), a daily quiz for PL/SQL developers; hundreds of programmers play each day. Check it out and join the fun! Steven's online technical cyberhome is located at www.ToadWorld.com/SF. You can also catch up on his latest, mostly non-PLSQL rants at http://feuerthoughts.blogspot.com.

Bill Pribyl is the primary author of Learning Oracle PL/SQL and the coauthor of Oracle PL/SQL Programming and its companion pocket reference, all from O'Reilly Media. He is oddly proud of having used PL/SQL to write TCP/IP networking clients, tnsping callouts, near-realtime commodity price loaders, and transcendental functions. Bill, who holds a degree in physics from Rice University, is the former editor of the IOUG technical journal (Select) and former president of the South Central Oracle Users Group. At home with his family in Houston, Texas, Bill's current nonbillable titles include Webmaster for his neighborhood civic club, "IT Guy" for his son's Boy Scout troop, and Eucharistic Adoration Coordinator for his church. Visit Bill's firm at http://www.datacraft.com.

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >

Oracle PL/SQL Programming 4.9 out of 5 based on 0 ratings. 10 reviews.
rumtum More than 1 year ago
This is an essential book for PL programming.
Anonymous More than 1 year ago
*strolls in and sits on the couch*
Anonymous More than 1 year ago
Fine move to dg res one.
Anonymous More than 1 year ago
Crushes? Fasion? Makeup? Friends? Ask about all these and more at fasion result 2!!!!!!!
Anonymous More than 1 year ago
My ex is a total jerk!! He's always talking about how gross I am and always making wierd faces when I look at him. Once he even said it was the biggest mistake of his life to date me!!!! My heart shattered!!! What do I do?
Anonymous More than 1 year ago
Girl problem at res 6
Anonymous More than 1 year ago
This is not realated to boys or anything like that but i didnt know where else to put this so here it goes. I dont have a religon. Now, you must be thinking," Yes you do. Everyone does!" Well, I dont. I dont go to church, I dont say prayers, or anything of that sort. And im not Jewish( no offenese to those who are). My best friend is always talking about her church and how I should go there with her every Sunday. She tries to teach me about god and jesus and things like that but it doesnt make sense to me at all. When i say," Can we do something else?"she says,"No you need to learn this." I dont want to learn it. What should i tell her, and how do i say it without offending her?
Anonymous More than 1 year ago
Don't date someone you don't like just because you think your friend will get mad at you. Talk to her and say, "l think your brother is a sweet and awesome person. I just don't have a romantic attraction to him. That could change, but not anytime soon." If she is a good friend she will understand.<p> About Mikey: it's obvious from your description that Mikey possibly might have a mental or emotional disorder, or very light autism. I think you should keep your distance from him and stop thinking about him. If he kicked a girl there is a BIG problem. Just forget about him. That sounds harsh, but it's true. Remember the good times you had together, acknowledge them, and move on. You'll be happier for it.
Anonymous More than 1 year ago
No problem. :D If you need anything ir just want to talk, find me through FlareStrike.
Anonymous More than 1 year ago
Okay!