Hitachi

Hitachi Advanced Database SQL Reference


8.12.1 ASCII

Returns the character code of the first character of the target data as an integer value.

Organization of this subsection

(1) Specification format

scalar-function-ASCII ::= ASCII(target-data)
 
  target-data ::= value-expression

(2) Explanation of specification format

target-data:

Specifies the target data.

The following rules apply:

  • Specify the target data in the form of a value expression. For details about value expressions, see 7.20 Value expression.

  • Specify CHAR or VARCHAR type data for the target data.

  • You cannot specify a dynamic parameter by itself for the target data.

The following example illustrates the result of executing the scalar function ASCII. The example assumes Unicode (UTF-8) as the character encoding.

Examples:

ASCII('A')65

ASCII('ABCD')65

ASCII('[Figure]')14845345

(3) Rules

  1. The data type of the execution result is the INTEGER type.

  2. The NOT NULL constraint does not apply to the value of the execution result (the null value is allowed).

  3. In either of the following cases, the execution result will be a null value:

    • If the target data is the null value

    • If the actual length of the target data is 0 bytes or 0 characters

(4) Example

Example:

From the character string data items in column C1 of table T1, find the character string data items for which the first character falls in the range of ASCII codes.

SELECT "C1" FROM "T1" WHERE ASCII("C1")<128

[Figure]