Oracle PL/SQL Tutorial/Character String Functions/ASCII

Материал из SQL эксперт
Перейти к: навигация, поиск

ASCII(0), ASCII(9)

SQL>
SQL> select ASCII(0), ASCII(9) FROM dual;
  ASCII(0)   ASCII(9)
---------- ----------
        48         57


ASCII("A") ASCII("Z") ASCII("A") ASCII("Z") ASCII("ABC")

SQL>
SQL>
SQL> select ascii("a"), ascii("z")
  2  ,      ascii("A"), ascii("Z")
  3  ,      ascii("ABC"), chr(77)
  4  from   dual;
ASCII("A") ASCII("Z") ASCII("A") ASCII("Z") ASCII("ABC") C
---------- ---------- ---------- ---------- ------------ -
        97        122         65         90           65 M
SQL>


Ascii gives the ASCII value of the first character of a string

The general format for this function is: ASCII(string)



SQL>
SQL> SELECT ASCII("first") FROM dual;
ASCII("FIRST")
--------------
           102


ASCII(x) gets the ASCII value of the character x

CHR() and ASCII() have the opposite effect.

The following example gets the ASCII value of a, A, z, Z, 0, and 9 using ASCII().



SQL> SELECT ASCII("a"), ASCII("A"), ASCII("z"), ASCII("Z") from dual;
ASCII("A") ASCII("A") ASCII("Z") ASCII("Z")
---------- ---------- ---------- ----------
        97         65        122         90
SQL>


select ascii("a"), ascii("z"),ascii("A"), ascii("Z"),ascii("ABC"), chr(77)

SQL>
SQL>
SQL> select ascii("a"), ascii("z"),ascii("A"), ascii("Z"),ascii("ABC"), chr(77)
  2  from   dual;
ASCII("A") ASCII("Z") ASCII("A") ASCII("Z") ASCII("ABC") C
---------- ---------- ---------- ---------- ------------ -
        97        122         65         90           65 M
SQL>