The following types of literals (constant values) can be used in Advantage SQL statements.
A sequence of characters enclosed in single quotes. In versions 7.0 and earlier, the maximum length of a string literal is 1024. In versions 7.1 and later, there is no specific limit on character literal length; they can be arbitrarily long. To represent a single quote itself within a character string literal, use two adjacent single quotes (e.g., 'Mark''s text'). Note that character string literals cannot be enclosed in double quotes; those are reserved for delimiting identifiers such as field or table names that have non-standard characters or are reserved keywords.
A sequence of digits proceeded by an optional sign (+/-) and with an optional decimal point. In addition, scientific notation can be used. The following are examples of valid numeric literals: 7, 3.14159, -5, 2.6e-4. Note that the decimal point must be represented by a period. A comma is not recognized as a valid decimal point.
The numeric literal may be interpreted as either exact numeric or approximate numeric (see Exact Numeric vs Approximate Numeric) using the following rules:
|1.||Numeric literals in scientific notation are always interpreted approximate numeric.|
|2.||Numeric literals with no decimal point are interpreted as exact numeric Integer type, unless its value exceeds the range supported by a 4-byte integer. When the value exceeds the range of a 4-byte integer, the numeric literal will be interpreted as either an exact numeric Numeric type or an approximate numeric according to rule 3 and 4.|
|3.||If a numeric literal cannot be interpreted as an approximate numeric using rule 1 or an Integer using rule 2, it will be interpreted as an exact numeric Numeric type unless the precision of the numeric literal (number of digits) exceeds the maximum supported numeric precision (i.e., 30 in current implementation). The precision of the exact numeric will be the number of digits in the numeric literal and the scale of the numeric will be the number of digits after the decimal point.|
|4.||All other numeric literals are interpreted as approximate numeric. The internal representation of approximate numeric is IEEE Double.|
-5, 5, 1000, 1234567890 : Exact numeric Integer
1234567890123, 1.23, -1.000 : Exact numeric Numeric
2.6e-4, 1.234567890123456789012345678901234, 98765432109876543210987654321099 : Approximate numeric Double
How the numeric literal values are written in the SQL statement and interpreted by the SQL engine affects the outcome of the algebraic expression using the numeric literals. If a specific type is desired, the Convert() and Cast() scalar can be used to obtain the value in the required type. See Exact Numeric vs Approximate Numeric for more detail.
Represented by numeric values 0 and 1. In addition, the reserved keywords FALSE and TRUE can be used as aliases for 0 and 1 respectively.
A string literal with either the ANSI date format 'YYYY-MM-DD' or the default date format specified in your application via the "set date format" operation. With the Advantage Client Engine API or Advantage OLE DB Provider, the date format for an application can be specified via the AdsSetDateFormat API. With Advantage TDataSet Descendant applications, the date format for an application can be specified via the TAdsSettings.DateFormat property. If the ANSI style format (YYYY-MM-DD) and the format specified through the client's "set date format" operation are ambiguous, the ANSI format is assumed. For example, if the client format was 'YYYY-DD-MM', the date '1999-01-22' will be interpreted as January 22, 1999.
A string literal of the format 'HH:MM' or 'HH:MM:SS'. In addition 'am' or 'pm' can be included on the end if 12-hour time formats are desired. If the am/pm indicator is excluded, it is assumed that the time is in 24-hour format. The following are examples of valid time literals: '01:05', '10:30 am', '06:25:15 pm', '14:00'.
A string literal of the format 'YYYY-MM-DD HH:MM:SS.mmm' where the milliseconds at the end is optional. The time portion of timestamp literals must be in 24-hour time and must include the seconds value. The date portion can optionally conform to the date format specified by the client (see the description for the date literal above). The following are examples of valid timestamp literals: '1999-01-22 01:30:00', '2000-12-31 23:59:59.999'. If the client date format were MM/DD/YYYY, then '01/22/1999 12:30:00' would be a valid timestamp literal.
Binary String Literals
A binary string literal is a series of hexadecimal characters, the digits 0-9 and uppercase and lowercase letters A-F. Binary string literals must be prefixed with x and contain an even number of hexadecimal characters to the right of the prefix. Spaces can be inserted between hexadecimal characters to improve readability and will be ignored. The integer value 42 can be represented with the following binary string literals, x’00 00 00 2A’ or x’0000002A’. An unlimited number of characters may follow the x prefix. See Functions to Convert Hexadecimal Values.