A constant is a data item whose value cannot be changed in a program. This subsection explains how to specify constants. For details about the types of data values that can be specified by constants, see 3.3 CQL data types.
Constants include numeric constants for expressing numeric values and character string constants for expressing character strings.
The following types of numeric constants are available:
The following types of character string constants are available:
When specifying date and time constants, the specified values must be entered according to the time zone of the JavaVM on which Stream Data Platform - AF is running.
The following table shows the notations for constants.
Table 3-4 Notations for constants
No. | Constant | Notation | Data type in the stream data processing engine | ||
---|---|---|---|---|---|
1 | Numeric constant | Integer constant | For INTEGER: [sign]integer For BIGINT: [sign]integer[L|l] Examples: -123 45 6789L | For integer, specify a series of numbers. Specify + or - for the sign. The data type of a constant that ends with either character L or character l is BIGINT. | INTEGER, BIGINT |
Floating point constant | Decimal format: [sign]integer-portion.decimal-portion Examples: -12.3 456.0 0.789 | Integers are used to enter both the integer and decimal portions, separated by the decimal point (.). The integer portion, the decimal portion, and the decimal point (.) must always be entered. Specify + or - for the sign. | DOUBLE | ||
Decimal constant | Decimal format: [sign]integer-portion[.decimal-portion] {D|d} Examples: -12.3D 456.0d 0.789d -123D 45d | Integers are used to enter both the integer and decimal portions, separated by the decimal point (.). Specify + or - for the sign. The integer portion and either the character D or the character d at the end must always be entered. The decimal portion and the decimal point (.) are optional. | DECIMAL NUMERIC | ||
2 | Character string constant | 'character-string' Examples: 'HITACHI' '98' 'DB0002' | Specify a character string of single-byte characters or double-byte characters, enclosed in single quotation marks ('), for character-string#. To include a single quotation mark (') in the character string, use two consecutive single quotation marks ('') to enter a single quotation mark. For example, to specify one single quotation mark in a character string, enter ''''. For details about the specification formats for date data, time data, and timestamp data, see (2) Character string showing dates, (3) Character string showing time, and (4) Character string showing timestamp data. | VARCHAR |
Specify dates using the following format:
'YYYY-MM-DD'
To enter a date constant in a character string expression, enter the year (YYYY), month (MM), day (DD) separated by hyphens (-). If there are less digits than required for the year (YYYY), month (MM), or day (DD), enter leading zeros. Do not insert spaces between the numbers and the hyphen.
An example is shown below in which a character string showing a date is entered as a constant.
Note the following points when specifying dates:
Specify time using the following format:
'hh:mm:ss'
To enter a time constant in a character string expression, enter the hour (hh), minutes (mm), and seconds (ss) separated by colons (:). If there are fewer digits than required for the hour (hh), minutes (mm), or seconds (ss), enter leading zeros. Do not insert spaces between the numbers and the colon.
An example is shown below in which a character string showing time is entered as a constant.
Note the following points when specifying time data:
Specify timestamp data in the following format:
'YYYY-MM-DDhh:mm:ss[.SSSSSSSSS]'
To enter a timestamp constant in a character string expression, enter the year (YYYY), month (MM), day (DD) separated by hyphens (-), enter a single-byte space, and then enter the hour (hh), minutes (mm), and seconds (ss) separated by colons (:). If there are fewer digits than required for the year (YYYY), month (MM), day (DD), hour (hh), minutes (mm), or seconds (ss), enter leading zeros. Do not insert spaces between the numbers and the hyphen or between the numbers and the colon. Be sure to enter a single-byte space between the day (DD) and the hour (hh).
An example is shown below in which a character string showing a timestamp is entered as a constant.
Note the following points when specifying timestamp data: