Literals in pl/sql, PL-SQL Programming

Assignment Help:

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.


Related Discussions:- Literals in pl/sql

Components of an object type - parameter self, Parameter SELF in pl/sql ...

Parameter SELF in pl/sql The MEMBER methods recognize a built-in parameter named SELF that is an instance of the object type. Whether declared explicitly or implicitly, it is

Passing cursor parameters, Passing Cursor Parameters You use the OPEN ...

Passing Cursor Parameters You use the OPEN statement to pass the parameters to a cursor. Unless you want to accept the default values, each proper parameter in the cursor decl

Best practices/Data Warhousing, What are 3 good practices of modeling and/o...

What are 3 good practices of modeling and/or implementing data warehouses?

Data types in sql - timestamp, Data Types in SQL - Timestamp TIMESTAMP...

Data Types in SQL - Timestamp TIMESTAMP for values representing points in time on a specified uniform scale. DATE is used for timestamps on a scale of one day, such as DATE '2

Block structure in pl/sql, Block Structure The PL/SQL is a block-struct...

Block Structure The PL/SQL is a block-structured language. That is, the fundamental units (procedures, anonymous blocks, and functions) that make up a PL/SQL program are logi

Effects of null for union - sql, Effects of NULL for union - SQL The ...

Effects of NULL for union - SQL The treatment of NULL in invocations of EXCEPT is as for UNION. This is different from its treatment in those of NOT IN and quantified compari

I want database development with analysis tools, Project Description: I ...

Project Description: I want a database for large governmental and private data sets on one country that will be easily extended to other countries in the future. Also, the datab

Between and not between operator in sql, BETWEEN and NOT BETWEEN Operator i...

BETWEEN and NOT BETWEEN Operator in SQL Example: Restricting exam marks to between 0 and 100 CREATE ASSERTION Marks_between_0_and_100 CHECK (NOT EXISTS (SELECT * FROM

Using lock table, Using LOCK TABLE You use the LOCK TABLE statement to...

Using LOCK TABLE You use the LOCK TABLE statement to lock the whole database tables in the specified lock mode so that you can share or deny the access to them. For illustrati

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

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