Oracle PL/SQL - CHR Function

CHR Function : 

Syntax : CHR (number);
               CHR (number USING NCHAR_CS)

  • In Oracle PL/SQL CHR function returns a ASCII equivalent of the input numeric value that is passed to the function.
  • The Function will return a national character if you specify USING NCHAR_CS
Example 1: 

SELECT CHR(72)||CHR(69)||CHR(76)||CHR(76)||CHR(79)"RESULT" FROM DUAL;
RESULT
-------
HELLO 
Example 2 :

SELECT CHR (50052 USING NCHAR_CS) "RESULT" FROM DUAL; 
RESULT 
-- ---
Ä 

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