Constant Values
There are four basic types of constants: string, number, Boolean, and date.
String
A string value is a quoted character sequence. Both single quotes and double quotes are accepted.
city = 'New York' or city = "New York"
If a single or double quote is part of the string value, it needs to be escaped if the value is quoted using the same character. To escape a quote character, repeat the character twice, e.g.,
'Seven O''Clock'
Number
A number can be either an integer or a double.
age > 55
A double number can be entered using either decimal notation, or scientific notation,
ratio < 2.5
Numeric comparison is always done in double values. Therefore, an integer 50 does not equal a double 50.1. All arithmetic computation is also done in doubles. All values are converted to a double before the computation is performed. A division of two integer numbers results in a double value. No rounding is done regardless of the type of the operands.
Boolean
A Boolean constant is specified using ‘true’ or ‘false’. The case is insignificant.
instock = true
Date
There is no date constant in an expression. Instead, converting a text representation of a date to a date object can create a date value. The conversion is done using the to_date() function.
birthday > to_date("1960-12-31")
The default date format is the same as SQL, yyyy-MM-dd. An alternative date format can be supplied in the second argument of the function call:
birthday > to_date("12/31/60 12:00:00","MM/dd/yy HH:mm:ss")
The format should conform to the format defined in the java.text.SimpleDateFormat class.