home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Oracle PL/SQL Programming, 2nd Edition

Oracle PL/SQL Programming, 2nd EditionSearch this book
Previous: 1.7 Best Practices for PL/SQL Excellence Chapter 2 Next: 2.2 Identifiers
 

2. PL/SQL Language Fundamentals

Every language -- whether human or computer -- has a syntax, vocabulary, and character set. In order to communicate within that language, you have to learn the rules that govern its usage. Many of us are very wary of learning a new computer language. Change is often scary, but, in general, programming languages are very simple tongues, and PL/SQL is a relatively simple programming language. The difficulty we have conversing in languages based on bytes is not with the language, but with the compiler or computer with which we are having the discussion. Compilers are, for the most part, very stupid. They are not creative, sentient beings. They are not capable of original thought. Their vocabulary is severely limited. Compilers just happen to think their dull thoughts very, very rapidly -- and very inflexibly.

If I hear someone ask "gottabuck?", I can readily interpret that sentence and decide how to respond. If I instruct PL/SQL, on the other hand, to "gimme the next half-dozen records," I will not get very far in my application. To use the PL/SQL language, you must dot your i's and cross your t's -- syntactically speaking. So, in this chapter, I cover the fundamental language rules that will help you converse with the PL/SQL compiler -- the PL/SQL character set, lexical units, PRAGMA keyword, and block structure.

2.1 The PL/SQL Character Set

A PL/SQL program consists of a sequence of statements, each of which is made up of one or more lines of text. Text is made up of combinations of the characters shown in Table 2.1 .


Table 2.1: PL/SQL Character Set

Type

Characters

Letters

A-Z, a-z

Digits

0-9

Symbols

~ ! @ # $ % & * ( ) _ - + = | [ ] { } : ; " ' < > , . ? /

Whitespace

Tab, space, carriage return

Note that PL/SQL is a case-insensitive language. Uppercase letters are treated the same way as lowercase letters except when the characters are surrounded by single quotes (when they are literal strings) or represent the value of a character variable.

Every valid statement in PL/SQL, from declaration to executable statement to keyword, is made up of various combinations of the above characters. Now you just have to figure out how to put them all together!

A number of these characters -- both singly and in combination with other characters -- have a special significance in PL/SQL. Table 2.2 lists these special symbols.


Table 2.2: Simple and Compound Symbols in PL/SQL

Symbol

Description

;

Semicolon: statement terminator

%

Percent sign: attribute indicator (cursor attributes like %ISOPEN and indirect declaration attributes like %ROWTYPE). Also used as multibyte wildcard symbol, as in SQL.

_

Single underscore: single-byte wildcard symbol, as in SQL

:

Colon: host variable indicator, such as :block.item in Oracle Forms

**

Double asterisk: exponentiation operator

< > and !=

"Not equals"

||

Double vertical bar: concatenation operator

<< and >>

Label delimiters

<= and >=

Relational operators

:=

Assignment operator

=>

Association operator for positional notation

 --

Double dash: single-line comment indicator

/* and */

Beginning and ending multiline comment block delimiters

Characters are grouped together into lexical units, also called atomics of the language, because they are the smallest individual components. A lexical unit in PL/SQL is any of the following:

  • Identifier

  • Literal

  • Delimiter

  • Comment

These are described in the following sections.


Previous: 1.7 Best Practices for PL/SQL Excellence Oracle PL/SQL Programming, 2nd Edition Next: 2.2 Identifiers
1.7 Best Practices for PL/SQL Excellence Book Index 2.2 Identifiers

The Oracle Library Navigation

Copyright (c) 2000 O'Reilly & Associates. All rights reserved.

Library Home Oracle PL/SQL Programming, 2nd. Ed. Guide to Oracle 8i Features Oracle Built-in Packages Advanced PL/SQL Programming with Packages Oracle Web Applications Oracle PL/SQL Language Pocket Reference Oracle PL/SQL Built-ins Pocket Reference