Purpose
This function returns the ASCII value of the leftmost character of a character expression.
Syntax
ASCII(char)
Parameters
| Parameter | Description |
|---|---|
| char | An expression that is of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type. |
Return type
Returns a NUMBER data type.
Examples
Use the ASCII function to return the ASCII code values of A, 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
Use the ASCII function to return the ASCII value for A, a, a non-ASCII character, and space.
obclient> SELECT ASCII('A') A, ASCII('a') a, ASCII(' ') space,ASCII('<non_ascii_char>') hz FROM DUAL;
+------+------+-------+----------+
| A | A | SPACE | HZ |
+------+------+-------+----------+
| 65 | 97 | 32 | 14989485 |
+------+------+-------+----------+
1 row in set