Literals
Introduction
Literals are used for queries in the Administrator, they can also be used instead of variables in programming code with Db.SlowSQL
although, this comes with a heavy performance penalty.
Boolean
A boolean literal can have one of the two values true and false, which are represented by the two reserved words TRUE
and FALSE
. See example below.
Numeric
There are three types of numerical literals Int64
, Decimal
and Double
.
An Int64
literal is described by its integer value, as in example below.
A Decimal
literal is described by its numerical value including a decimal point, as in example below.
A Double
literal is described by two numerical values, the mantissa and the exponent, separated by the character E
. The mantissa may include a decimal point, but the exponent may not. See example below.
String
A string literal is a sequence of characters beginning and ending with single quote characters. To represent a single quote character within a String literal, you write two consecutive single quote characters, as in example below.
Date-time
A date-time literal is either described by the reserved word DATE
followed by a String
literal of the form yyyy-mm-dd
, the reserved word TIME
followed by a String
literal of the form hh:mm:ss[.nnn]
(the specification of milliseconds is optional), or the reserved word TIMESTAMP
followed by a String
literal of the form yyyy-mm-dd hh:mm:ss[.nnn]
. See examples below.
Note that all date-time literals in fact are timestamps, which means that the date-time literal in the first query above does not represent the date '2006-11-01'
but in fact the first millisecond of that date '2006-11-01 00:00:00.000'
. Consequently, above examples are equivalent.
Binary
A binary literal is described by the reserved word BINARY
and the binary value represented by a Hexadecimal string, as in example below.
Object
Since Starcounter SQL supports object references, you also need a way to represent an object reference to a specific object, i.e. an object literal. Every object in a Starcounter database can be identified by its unique object-id-number. You describe an object literal by the reserved word OBJECT
followed by the object's object-id-number, as in example below.
Last updated