Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask PL-SQL Expert

Identifiers

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:

X

 t2

phone#

credit_limit

LastName

oracle$number

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:

money$$tree

SN##

try_again_

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

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:

"X+Y"

"last name"

"on/off switch"

"employee(s)"

"*** 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.

PL-SQL, Programming

  • Category:- PL-SQL
  • Reference No.:- M9509889

Have any Question?


Related Questions in PL-SQL

Continuing the project you have worked on in weeks 1-4 in

Continuing the project you have worked on in Weeks 1-4, in this final week, complete the following tasks: Refine your database and SQL statements by incorporating your instructor's feedback. Verify that the database comp ...

Purpose of the assessment with ulo mapping the purpose of

Purpose of the assessment (with ULO Mapping) The purpose of this assignment is to develop skills in managing data in databases and to gain understanding of data model development and implementation using a commercially a ...

For this assignment you will be provided a database backup

For this assignment, you will be provided a database backup for a database called FinanceDB. You will have to restore this backup to your own version of SQL Server. All of the questions in this assignment relate to the F ...

Assignment - queries functions and triggersaimthe aims of

Assignment - Queries, Functions and Triggers Aim The aims of this assignment are to: formulate SQL queries; populate an RDBMS with a real dataset, and analyse the data; design test data for testing SQL queries; create SQ ...

Complete the following tasksin microsoft access create the

Complete the following tasks: In Microsoft Access, create the database and tables that you identified in W3 Assignment 2. In Microsoft Word, write the SQL statements to create the database and tables. Write SQL statement ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As