Purpose
The ASCII code for the leftmost character of the char_expr argument is returned.
Syntax
ASCII(char)
Parameters
| Parameter | Description |
|---|---|
| char | An expression of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type. |
Return type
Returns a value of the NUMBER data type.
Examples
Use the ASCII function to return the ASCII values for A, a, and space.
obclient> SELECT ASCII('A') A, ASCII('a') a, ASCII(' ') space FROM DUAL;
+------+------+-------+
| A | A | SPACE |
+------+------+-------+
| 65 | 97 | 32 |
+------+------+-------+
1 row in set
Use the ASCII function to return the ASCII code values of A, a, Z, and a space.
obclient> SELECT ASCII('A') A, ASCII('a') a, ASCII(' ') space, ASCII('Z') z FROM DUAL;
+------+------+-------+-----+
| A | A | SPACE | Z |
+------+------+-------+-----+
| 65 | 97 | 32 | 90 |
+------+------+-------+-----+
1 row in set