Skip Headers
Oracle® Database PL/SQL User's Guide and Reference
10g Release 2 (10.2)

Part Number B14261-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

Literal Declaration

A literal is an explicit numeric, character, string, or Boolean value not represented by an identifier. The numeric literal 135 and the string literal 'hello world' are examples. For more information, see "Literals".

Syntax

numeric literal ::=

Description of numeric_literal.gif follows
Description of the illustration numeric_literal.gif

integer literal ::=

Description of integer_literal.gif follows
Description of the illustration integer_literal.gif

real number literal ::=

Description of real_literal.gif follows
Description of the illustration real_literal.gif

character literal ::=

Description of char_literal.gif follows
Description of the illustration char_literal.gif

string literal ::=

Description of string_literal.gif follows
Description of the illustration string_literal.gif

boolean literal ::=

Description of boolean_literal.gif follows
Description of the illustration boolean_literal.gif

Keyword and Parameter Description

character

A member of the PL/SQL character set. For more information, see "Character Sets and Lexical Units".

digit

One of the numerals 0 .. 9.

TRUE, FALSE, NULL

A predefined Boolean value.

Usage Notes

Integer and real numeric literals can be used in arithmetic expressions. Numeric literals must be separated by punctuation. Spaces can be used in addition to the punctuation. For additional information, see "Numeric Literals".

A character literal is an individual character enclosed by single quotes (apostrophes). Character literals include all the printable characters in the PL/SQL character set: letters, numerals, spaces, and special symbols. PL/SQL is case sensitive within character literals. For example, PL/SQL considers the literals 'Q' and 'q' to be different. For additional information, see "Character Literals".

A string literal is a sequence of zero or more characters enclosed by single quotes. The null string ('') contains zero characters. A string literal can hold up to 32,767 characters. PL/SQL is case sensitive within string literals. For example, PL/SQL considers the literals 'white' and 'White' to be different.

To represent an apostrophe within a string, enter two single quotes instead of one. For literals where doubling the quotes is inconvenient or hard to read, you can designate an escape character using the notation q'esc_char ... esc_char'. This escape character must not occur anywhere else inside the string.

Trailing blanks are significant within string literals, so 'abc' and 'abc ' are different. Trailing blanks in a string literal are not trimmed during PL/SQL processing, although they are trimmed if you insert that value into a table column of type CHAR. For additional information, including NCHAR string literals, see "String Literals".

The BOOLEAN values TRUE and FALSE cannot be inserted into a database column. For additional information, see "BOOLEAN Literals".

Examples

Several examples of numeric literals are:


25 6.34 7E2 25e-03 .1 1. +17 -4.4 -4.5D -4.6F

Several examples of character literals are:


'H' '&' ' ' '9' ']' 'g'

Several examples of string literals are:


'$5,000'
'02-AUG-87'
'Don''t leave until you''re ready and I''m ready.'
q'#Don't leave until you're ready and I'm ready.#'

For examples, see the following:


Example 2-3, "Using DateTime Literals"
Example 2-34, "Using Conditional Compilation With Database Versions"

Related Topics


"Constant and Variable Declaration"
"Expression Definition"
"Literals"