w3resource

Oracle ASCII function

Description

The ASCII() function returns the decimal representation of the first character of a character expression.

Character expression can be the following data types:

  • CHAR
  • VARCHAR2
  • NCHAR
  • NVARCHAR2

The function does not support CLOB data directly. However, CLOBs can be passed in as arguments through implicit data conversion.

Note : If your database character set is 7-bit ASCII, then this function returns an ASCII value. If your database character set is EBCDIC Code, then this function returns an EBCDIC value.

Syntax:

ASCII(character_expression)

Parameters:

Name Description
character_expression Is an expression of the above data types mentioned in the list.

Return Value Type:

NUMBER.

Applies to:

Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Examples: Oracle ASCII function

The following example returns employees whose first names begin with the letter 'C', whose ASCII equivalent is 67:

SQL> SELECT first_name  FROM employees
  2  WHERE ASCII(SUBSTR(first_name, 1, 1)) = 67
  3  ORDER BY last_name;

Sample Output:

FIRST_NAME
--------------
Curtis
Charles
Christopher
Clara

Previous: UPPER
Next: INSTR



Share this Tutorial / Exercise on : Facebook and Twitter