Identifiers in pl/sql, PL-SQL Programming

Assignment Help:

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.


Related Discussions:- Identifiers in pl/sql

Write a stored procedure, a. Create a table odetails_new. It has all the a...

a. Create a table odetails_new. It has all the attributes of odetails and an additional column called cost, whose values are the product of the quantity and price of the part bein

Exception handling, Exception handling In the PL/SQL, a warning or erro...

Exception handling In the PL/SQL, a warning or error condition is known as an exception. The Exceptions can be internally defined (by the run-time system) or user defined. The

Comparison operators- pl/sql, Comparison Operators The Comparison operat...

Comparison Operators The Comparison operators can compare one expression to another. The outcome is always true, false, or null. Usually, you use a comparison operators in condi

Authorize and fetch data from instagram, Authorize and fetch data from Inst...

Authorize and fetch data from Instagram Project Description: Incorporate Instagram feed on mobile site platform: c#, ms sql, jquerymobile, jquery Web admin Author

PROCEDURE, Create a procedure named DDPROJ_SP that retrieves project inform...

Create a procedure named DDPROJ_SP that retrieves project information for a specific project based on a project ID. The procedure should have two parameters: one to accept a projec

Design a script and integrate procedures, Initial thought process: Design...

Initial thought process: Design a script which was simple and user friendly. Integrate procedures/functions to extract data under the hood. I focused on giving the user the opt

Controlling autonomous transactions, Controlling Autonomous Transactions ...

Controlling Autonomous Transactions The first SQL statement in an autonomous routine starts a transaction. Whenever one transaction ends, the next SQL statement starts the oth

Naming conventions-pl/sql, Naming Conventions The similar naming conventi...

Naming Conventions The similar naming conventions apply to all PL/SQL program items and units including the variables, cursors, constants, cursor variables, procedures, exception

Using default-declarations in sql, Using DEFAULT You can use the keyword...

Using DEFAULT You can use the keyword DEFAULT rather than that of the assignment operator to initialize the variables. For e.g. the declaration blood_type CHAR := ’O’; it can b

Nested tables versus index-by tables, Nested Tables versus Index-by Tables ...

Nested Tables versus Index-by Tables The Index-by tables and nested tables are just similar. For e.g.  They have similar structure and their individual elements are accessed in

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd