Purpose
You can call this function to return the ASCII code value of the leftmost character in a character expression.
Syntax
ASCII(char)
Parameters
| Parameter | Description |
|---|---|
| char | An expression of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type. |
Return type
The return type is NUMBER.
Examples
The following example uses the ASCII function to return the ASCII code values of the letters A and a and a space.
obclient> SELECT ASCII('A') A, ASCII('a') a, ASCII(' ') space FROM DUAL;
+------+------+-------+
A A SPACE
+------+------+-------+
65 97 32
+------+------+-------+
1 row in set
The following example uses the ASCII function to return the ASCII code values of letters A and a, and a space.
obclient> SELECT ASCII('A') A, ASCII('a') a, ASCII(' ') space,ASCII('65') hz FROM DUAL;
+------+------+-------+------+
| A | a | space | hz |
+------+------+-------+------+
| 65 | 97 | 32 | 54 |
+------+------+-------+------+
1 row in set