3.2.6 Specifying constants

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.

Organization of this subsection
(1) Constant types and notation
(2) Character string showing dates
(3) Character string showing time
(4) Character string showing timestamp data

(1) Constant types and notation

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.ConstantNotationData type in the stream data processing engine
1Numeric constantInteger constantFor 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 constantDecimal 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 constantDecimal 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
2Character 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
#
Double quotation marks (") cannot be used to enclose a character string. Double quotation marks cannot be used in a character string either (this is because it is not possible to escape double quotation marks in a character string).

(2) Character string showing dates

Specify dates using the following format:

'YYYY-MM-DD'

YYYY
0001 to 9999 (Year)
MM
01 to 12 (Month)
DD
01 to the last day of the month specified by MM (Day)

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.

Specification example of March 25, 2010
'2010-03-25'

Note the following points when specifying dates:

(3) Character string showing time

Specify time using the following format:

'hh:mm:ss'

hh
00 to 23 (hours)
mm
00 to 59 (minutes)
ss
00 to 59 (seconds)#
#
00 to 61 (seconds) if there is a leap second.

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.

Specification example of 10 pm, 8 minutes, 26 seconds
'22:08:26'

Note the following points when specifying time data:

(4) Character string showing timestamp data

Specify timestamp data in the following format:

'YYYY-MM-DD[Figure]hh:mm:ss[.SSSSSSSSS]'

YYYY
0001 to 9999 (Year)
MM
01 to 12 (Month)
DD
01 to the last day of the month specified by MM (Day)
hh
00 to 23 (hours)
mm
00 to 59 (minutes)
ss
00 to 59 (seconds)#
#
00 to 61 (seconds) if there is a leap second.
SSSSSSSSS
Fractional seconds of from 0 to 9 digits (S: 0 to 9)

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.

Specification example of 10 pm, 8 minutes, 26 seconds, August 1, 2008
'2008-08-01 22:08:26'

Note the following points when specifying timestamp data: