Introduction SQL

Basic SQL

SQL Constraints

Advance SQL

SQL Joins

SQL Function

SQL ASCII, CHR, NCHR Function


SQL ASCII Function

SQL ASCII function return the ASCII values of given argument.

Supported Oracle SQL Version :

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

Syntax :

ASCII(character)

Parameter :

character is single character that return ASCII value of given character.

Example :

Considering following example SQL ASCII function.

SQL> SELECT ASCII('J') FROM DUAL;

ASCII('J')
----------
        74

SQL> SELECT ASCII('E') FROM DUAL;

ASCII('E')
----------
        69

SQL> SELECT ASCII('M') FROM DUAL;

ASCII('M')
----------
        77

SQL CHR Function

SQL CHR function return the DECIMAL value of the given ASCII argument.

Supported Oracle SQL Version :

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

Syntax :

CHR(number)

Example :

Consider following example return the decimal value of given ASCII argument.

SQL> SELECT CHR(74) "CHR" FROM DUAL;

CHR
---
  J

SQL> SELECT CHR(69) "CHR" FROM DUAL;

CHR
---
  E

SQL> SELECT CHR(77) "CHR" FROM DUAL;

CHR
---
  M

SQL> SELECT CHR(74)||CHR(69)||CHR(77) "CHR JEM" FROM DUAL;

CHR JEM
-------
    JEM


SQL NCHR Function

SQL NCHR function return the DECIMAL value of the given ASCII argument (National character).

Supported Oracle SQL Version :

  • Oracle 9i
  • Oracle 10g
  • Oracle 11g
  • Oracle 12c

Syntax :

NCHR(number)

Example :

Consider following example return the decimal value of given ASCII argument.

SQL> SELECT NCHR(74) "NCHR" FROM DUAL;

NCHR
----
   J

SQL> SELECT NCHR(69) "NCHR" FROM DUAL;

NCHR
----
   E

SQL> SELECT NCHR(77) "NCHR" FROM DUAL;

NCHR
----
   M

SQL> SELECT NCHR(74)||NCHR(69)||NCHR(77) "NCHR JEM" FROM DUAL;

NCHR JEM
--------
     JEM