Show TOC

Syntax documentationLiterals Locate 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.

Syntax Syntax

  1. <literal> ::= <string literal> |
                         <exact numeric literal> |
                            <approximate numeric literal>.
    
End of the code.
String Literals

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

Example Example

  1. SELECT COUNT(*) FROM dbtab WHERE col = 'Hugo'
End of the code.

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.

Example Example

  1. DELETE FROM dbtab WHERE col = ''''
End of the code.

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

Note Note

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

End of the note.
Exact Numeric Literals

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

Syntax Syntax

  1. <exact numeric literal> ::= ( <digit> )+ ( '.' ( <digit> )* )? |
                                 '.' ( <digit> )+.
    
End of the code.

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 Example

Exact Numeric Literals
  1. 3
    3.5
    .5
    
End of the code.
Approximate Numeric Literal

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

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

End of the note.

Syntax Syntax

  1. <approximate numeric literal> ::= <exact numeric literal> 'E' ( '+' | '-' )? ( <digit> )+.
End of the code.

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

Approximate Numeric Literals.

Example Example

  1. 3E0
    3.5E-7
    .5E+03
    
End of the code.
Hex Literals

Open SQL does not support hex literals.

Date and Time Literals

Open SQL does not support date and time literals.