Oracle PL/SQL - ASCIISTR Function

ASCIISTR Function : 

Syntax : ASCIISTR ('input_string')

  • In Oracle PL/SQL ASCIISTR function takes a string (or an expression that resolves to a string) and returns an ASCII version of the string in the current database character set.
  • Non ASCII Characters are converted to the form \xxxx (in the below example \00C4) where \xxxx represents the UTF-16 code.
  • ASCIISTR is useful in converting the Unicode characters to a ASCII set value.

Example: 

SELECT ASCIISTR('XYZÄABC') FROM DUAL;

ASCIISTR
----------
XYZ\00C4ABC

Oracle PL/SQL String / Character Functions - ASCII Function

ASCII Function : 

Syntax : ASCII ('input_character')

  • In Oracle PL/SQL ASCII function returns the numeric value associated with a character.
  • Return Type of ASCII function is NUMBER.
  • This Function doesn't support CLOB datatype as input
  • Input_character should be of one character. If the input character has more than one letter, than the function takes the first character of the string.

In the below example the first result returns  the numeric equivalent of the character 'a'. In the second example, since more that one character is entered it has returned the ASCII value of the first character which is 'd'.

Example: 

ASCII('a')
Result: 97
ASCII('developersarena')
Result: 100