Print      Open PDF Version of Online Help


Previous Topic

Next Topic

Expressing Literals

A literal is a non-null value corresponding to a given data type. Literals are typically constant values; that is, they are values that are taken literally as is, without changing them at all. A literal value has to comply with the data type that it represents.

This section describes how to express each type of literal.

Character Literals

A character literal contains characters such as letters, numbers and symbols. To express a character literal, enclose the character string within single quotes ( ' ). The length of the literal is determined by the number of characters between the single quotes.

Date time Literals

The SQL 92 standard defines three kinds of typed date time literals in the following formats:

DATE 'yyyy-MM-dd'

TIME 'hh:MM:ss'

TIMESTAMP 'yyyy-MM-dd hh:mm:ss'

These formats are fixed. To express a typed date time literal, use the keywords DATE, TIME, or TIMESTAMP followed by a date time string enclosed in single quote marks. Two digits are required for all non-year components even if the value is a single digit.

Example:

CASE

WHEN Opportunity."Close Date" >= TIMESTAMP '2006-01-01 00:00:00' THEN '2006'

ELSE 'Pre-2006'

END

Numeric Literals

A numeric literal represents a value of a numeric data type. To express a numeric literal, simply include the number.

Do not enclose numeric literals within single quotes; doing so expresses the literal as a character literal.

A number can be preceded with either a plus sign (+) or minus sign (-) to indicate a positive or negative number, respectively. Numbers can contain a decimal point and decimal numbers.

To express floating point numbers as literal constants, enter a number followed by the letter E (either uppercase or lowercase) and followed by the plus sign (+) or the minus sign (-) to indicate a positive or negative exponent. No spaces are allowed between the integer, the letter E, and the sign of the exponent.

Examples:

52

2.98

-326

12.5E6


Published August 2018 Copyright © 2005, 2018, Oracle. All rights reserved. Legal Notices.