Skip to Main Content
Oracle PL/SQL Best Practices, 2nd Edition
book

Oracle PL/SQL Best Practices, 2nd Edition

by Steven Feuerstein
October 2007
Intermediate to advanced content levelIntermediate to advanced
292 pages
8h 38m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Best Practices, 2nd Edition

Chapter 4. What’s Code Without Variables?

PL/SQL is a strongly typed language. This means that before you can work with any kind of data structure, you must first declare it. And when you declare it, you specify its type and, optionally, an initial or default value. All declarations of these variables must be made in the declaration section of your anonymous block, procedure, function, or package. I’ve divided the best practices in this chapter into three main categories, described in the following sections:

Best Practices for Declaring Variables and Data Structures

Presents best practices for specifying %TYPE and %ROWTYPE, declaring SUBTYPEs, and localizing variable initialization.

Best Practices for Using Variables and Data Structures

Presents best practices for simplifying the specification of business rules and data structures and avoiding implicit datatype conversions.

Best Practices for Declaring and Using Package Variables

Presents best practices aimed particularly at the use of variables in packages.

Best Practices for Declaring Variables and Data Structures

Use the best practices described in this section when you declare your variables and data structures.

That column’s never going to change!

Always anchor variables to database datatypes using %TYPE and %ROWTYPE.

Problem: Lizbeth writes a “quick-and-dirty” program.

Lizbeth hates doing anything the quick-and-dirty way. In fact, she generally hates to be in a hurry at all. But Sunita comes by with an urgent request: “I need you to write ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle SQL*Plus: The Definitive Guide, 2nd Edition

Oracle SQL*Plus: The Definitive Guide, 2nd Edition

Jonathan Gennick
Oracle PL/SQL Programming, Third Edition

Oracle PL/SQL Programming, Third Edition

Steven Feuerstein, Bill Pribyl
Oracle PL/SQL Programming, 5th Edition

Oracle PL/SQL Programming, 5th Edition

Steven Feuerstein, Bill Pribyl

Publisher Resources

ISBN: 9780596514105Supplemental ContentErrata Page