Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask PL-SQL Expert

Literals

A literal is an explicit numeric, string, character, or Boolean value not represented by an identifier. Numeric literal 147 and the Boolean literal FALSE are some of the examples.

Numeric Literals

The 2 kinds of numeric literals can be used in an arithmetic expression: integers & reals. The  integer literal is an optionally signed whole number without a decimal point. Some of the examples are shown below:

030, 6, -14, 0, +32767

A real literal is an optionally signed whole or fractional number with a decimal point. Some of the examples are shown below:

6.6667, 0.0, -12.0, 3.14,159, +8300.0, 0 .5 25

The PL/SQL considers numbers like 12.0 and 25. to be real even if they have integral values.

The Numeric literals cannot contain dollar signs or commas, however can be written using the scientific notation. Just suffix the number with an E (or e) followed by an optionally signed integer. A few examples are shown below:

2E5 1.0E-7 3.14159e0 -1E38 -9.5e-3

The E stands for "times ten to the power of." As the next illustration represents, the number after E is the power of ten by which the number before E must be multiplied (the double asterisk (**) is the exponentiation operator):

5E3 = 5 10**3 = 5 1000 = 5000

The number after E also correspond to the number of places the decimal point shift. In the last illustration, the implicit decimal point shifted three places to the right. In this illustration, it shifts three places to the left:

5E-3 = 5 10**-3 = 5 0.001 = 0.005

As the example below shows, if the value of a numeric literal falls outside the range 1E-130... 10E125, you obtain a compilation error:

DECLARE

n NUMBER;

BEGIN

n := 10E127; -- causes a 'numeric overflow or underflow' error

Character Literals

A character literal is an individual character enclosed by single quotes (apostrophes). The Character literals include all the printable characters in the PL/SQL character set: numerals, letters, spaces, and special symbols. Some examples are as shown:

'Z' '%' '7' ' ' 'z' '('

The PL/SQL is case sensitive within the character literals. For example, PL/SQL considers

the literals 'Z' and 'z' to be different. Also the character literals '0'..'9' are not equivalent to the integer literals but can be used in the arithmetic expressions as they are implicitly convertible to integers.

String Literals

A character value can be represented by an identifier or explicitly written as a string literal that is a sequence of zero or more characters enclosed by single quotes. Several examples are shown below:

'Hello, world!'

'XYZ Corporation'

'10-NOV-91'

'He said "Life is like licking honey from a thorn."'

'$1,000,000'

All the string literals except the null string ('') have datatype CHAR. Given that the apostrophes (single quotes) delimit string literals, how do you show an apostrophe within a string? As the next illustration shows, you write two single quotes that are not similar as writing a double quote:

"'Don't leave without saving the work."

The PL/SQL is case sensitive within string literals. For illustration, PL/SQL considers the following literals to be different:

'baker'

'Baker'

Boolean Literals

The Boolean literals are the predefined values TRUE, FALSE, & NULL (which stand for an unknown, missing, or inapplicable value). Keep in mind; the Boolean literals are values, and not the strings. For illustration, TRUE is no less a value than the number 25.

PL-SQL, Programming

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

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