Show TOC

LiteralsLocate this document in the navigation 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.

<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.

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

String Literal . The number of rows in the table dbtab for which the column col has the value 'Hugo' is determined.

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

Sample Code
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.

<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 '.'.

Sample Code

Exact Numeric Literals

3
3.5
.5

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.

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

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

Approximate Numeric Literals.

Sample Code
3E0
3.5E-7
.5E+03

Hex Literals

Open SQL does not support hex literals.

Date and Time Literals

Open SQL does not support date and time literals.