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>. |
A <string literal> is a sequence of characters enclosed in single quotes '''. String literals are case sensitive.
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.
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.
You cannot assign a string literal to a CLOB column using an INSERT or UPDATE statement.
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 '.'.
3 3.5 .5 |
Exact Numeric Literals
Approximate numeric literals are used to express approximate numeric constants in SQL text.
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.
3E0 3.5E-7 .5E+03 |
Approximate Numeric Literals.
Open SQL does not support hex literals.
Open SQL does not support date and time literals.