Show TOC Start of Content Area

Syntax documentation Literals   Locate the document in its SAP Library structure

Literals represent constant values in the SQL text. Open SQL knows three different types of literals: the string literal, the exact numeric literal and the approximate numeric literal.

Syntax

Syntax

<literal> ::= <string literal> |

                     <exact numeric literal> |

                        <approximate numeric literal>.

String Literals

A <string literal> is a sequence of characters enclosed in single quotes '''. String literals are case sensitive.

Example

SELECT COUNT(*) FROM dbtab WHERE col = 'Hugo'

String Literal. The number of rows in the table dbtabfor which the column colhas the value 'Hugo'is determined.

The single quote itself is denoted as '' (two single quotes in sequence) inside the string literal.

Example

DELETE FROM dbtab WHERE col = ''''

Single Quote inside String Literal. All columns are deleted from the table dbtab for which the column col contains a single quote character.

Note

You cannot assign a string literal to a CLOB column using an INSERT or UPDATE statement.

Exact Numeric Literals

Exact numeric literals are use to express an exact numeric constant in SQL text.

Syntax

<exact numeric literal> ::= ( <digit> )+ ( '.' ( <digit> )* )? |

                             '.' ( <digit> )+.

The precision of an <exact numeric literal> is the number of digits it contains, the scale of an <exact numeric literal> is the number of digits right of the '.'.

Example

3

3.5

.5

Exact Numeric Literals

Approximate Numeric Literal

Approximate numeric literals are used to express approximate numeric constants in SQL text.

Note

If an approximate is part of a value expression, the database uses approximate arithmetic to determine the result of the expression. Therefore approximate numeric literals are inappropriate in calculations involving monetary values.

Syntax

<approximate numeric literal> ::= <exact numeric literal> 'E' ( '+' | '-' )? ( <digit> )+.

The precision of an <approximate numeric literal> is the precision of its mantissa.

Example

3E0

3.5E-7

.5E+03

Approximate Numeric Literals.

Hex Literals

Open SQL does not support hex literals.

Date and Time Literals

Open SQL does not support date and time literals.

End of Content Area