Related Articles

Related Articles

PLSQL | ASCII Function
  • Last Updated : 18 Sep, 2019

The string in PL/SQL is actually a sequence of characters with an optional size specification.
The characters could be numeric, letters, blank, special characters or a combination of all.
The ASCII Function in PLSQL is used to return the NUMBER code that represents the specified character.

Syntax

ASCII( single_character )

Parameters Used:

single_character – It is used to retrieve the NUMBER code for the specified character.
If more than one character is entered, the ASCII function will return the value for the first character and ignore all of the characters after the first.

Supported Versions of Oracle/PLSQL:

  1. Oracle 12c
  2. Oracle 11g
  3. Oracle 10g
  4. Oracle 9i
  5. Oracle 8i

Example:

DECLARE 
   Test_Char char := 'A';
   Test_Char2 char := 'H';
   Test_String varchar2(6) := 'Hello';
   
BEGIN 
   dbms_output.put_line(ASCII(Test_Char)); 
   dbms_output.put_line(ASCII(Test_Char2)); 
   dbms_output.put_line(ASCII(Test_String)); 
    
END; 

Output:

65
72
72
My Personal Notes arrow_drop_up
Recommended Articles
Page :