Identifiers in pl/sql, PL-SQL Programming


You use identifiers to name the PL/SQL program items and units that include constants, variables, cursors, exceptions, cursor variables, subprograms, and packages. Some of the examples of identifiers is shown below:







An identifier consists of a letter optionally followed by many letters, numerals, underscores, dollar signs, and number signs. Other characters like slashes, hyphens, and spaces are illegal, as the examples shown below:

mine&yours -- illegal ampersand

debit-amount -- illegal hyphen

on/off -- illegal slash

user id -- illegal space

The next examples represents that adjoining and trailing dollar signs, underscores, and number signs are permitted:




You can use lower, upper, or mixed case to write the identifiers. The PL/SQL is not case sensitive except within the string and character literals. Therefore, if the only difference between identifiers is the case of corresponding letters, then PL/SQL considers the identifiers to be similar, as the example shown below:


LastName-- same as lastname

LASTNAME-- same as lastname and LastName

The length of an identifier may not exceed 30 characters. But, each character, involving underscores, dollar signs, and number signs, is significant. For example, the PL/SQL  considers the following identifiers to be different:

lastname last_name

Identifiers must be descriptive. And hence, avoid obscure names like cpm. Rather, use of meaningful names like cost_per_thousand.

Predefined Identifiers

The Identifiers worldwide declared in package STANDARD, like the exception INVALID_NUMBER, can be re-declared. Though, re-declaring predefined identifiers is error prone as your local declaration overrides the global declaration.

Quoted Identifiers

For flexibility, the PL/SQL encloses identifiers within the double quotes. The Quoted identifiers are seldom required, but rarely can they be useful. They can contain any sequence of printable characters together with spaces but excluding the double quotes. And hence, the following identifiers are valid:


"last name"

"on/off switch"


"*** header info ***"

The highest length of a quoted identifier is 30 characters not counting the double quotes. However allowed, using the PL/SQL reserved words as quoted identifiers is a poor programming practice.

Some of the PL/SQL reserved words are not reserved by the SQL. For example, you can use the PL/SQL reserved word TYPE   in a CREATE TABLE  statement to name a database column. But, if a SQL statement in your program refers to that column, you get a compilation error, as the following example is shown below:

SELECT acct, type, bal INTO ...-- causes compilation error

To prevent the error, enclose the uppercase column name in double quotes, as shown below:

SELECT acct, "TYPE", bal INTO ...

The column name cannot appear in the lower or mixed case (unless it was defined that way in the CREATE TABLE statement). For example, the statement below is invalid:

SELECT acct, "type", bal INTO ...-- causes compilation error

Otherwise, you can create a view that renames the troublesome column, then use the view rather of the base table in SQL statements.

Posted Date: 10/2/2012 2:05:28 AM | Location : United States

Related Discussions:- Identifiers in pl/sql, Assignment Help, Ask Question on Identifiers in pl/sql, Get Answer, Expert's Help, Identifiers in pl/sql Discussions

Write discussion on Identifiers in pl/sql
Your posts are moderated
Related Questions
%NOTFOUND The %NOTFOUND is the logical opposite of the %FOUND. The %NOTFOUND yields TRUE when an INSERT, UPDATE, or DELETE statement affected no rows, or the SELECT INTO state

Recursion versus Iteration Dissimilar the iteration, recursion is not crucial to PL/SQL programming. Any problem which can be solved using recursion can be solving using the it

Using Aggregation on Nested Tables Example is the most direct translation of its counterpart in the theory book that can be obtained in SQL but it is so over-elaborate that no

Manipulating Local Collections Within PL/SQL, to manipulate the local collection, by using the  TABLE and CAST operators . The operands of CAST are a collection declared locally

PL SQL Code Review HEADER ELEMENTS File Name Clear, meaningful and descriptive about main objective of the file. Multiple words are joined using underscores which adh

Rephrase Conditional Control Statements When computing a logical expression, the PL/SQL uses short-circuit evaluation. That is, the PL/SQL stops evaluating the expression as s

ORIGIN OF EARTH - BIG-BAN G HYPOTHESIS - Origin of life is linked to origin of earth. Cosmos, the Universe originated 10-20 billion years ago by Big Bang (thermonu

Positional and Named Notation You can write the actual parameters when calling a subprogram, using either positional or named notation. That is, you can point to the relationsh

Challenge 1 You are required to do the project and write a test plan for it. Demo 4 is a check writer program for employees. In it, the user enters all information about the

Aggregate Operators SQL Supports all of the aggregate operators mentioned in the theory book and many more besides. The syntax, however, involves an unusual trick that SQL cal