ORACLE ASCII FUNCTION
oracle ascii function finds ascii value of the char.
SYNTAX: ascii(char)
SQL>select ascii('a') from dual;
ascii('a')
--------------------
97
SQL> select ascii('ab') from dual;
ASCII('AB')
-----------
97
ASCII('AB')
-----------
97
Note: ascii value of ab , it takes only first character. i.e a
Ascii value of blank is 32.
SQL>select ascii(' ') from dual;
ascii(' ')
--------------
32
DISPLAY ASCII VALUES OF THE STRING
------------------------------------------------------------
declare
v varchar2(20):='hello oracle!';
c char;
begin
for i in 1..length(v)
loop
c:=substr(v,i,1);
dbms_output.put_line(c||'='||ascii(c));
end loop;
end;
v varchar2(20):='hello oracle!';
c char;
begin
for i in 1..length(v)
loop
c:=substr(v,i,1);
dbms_output.put_line(c||'='||ascii(c));
end loop;
end;
SQL> /
h=104
e=101
l=108
l=108
o=111
=32
o=111
r=114
a=97
c=99
l=108
e=101
!=33
PL/SQL procedure successfully completed.
h=104
e=101
l=108
l=108
o=111
=32
o=111
r=114
a=97
c=99
l=108
e=101
!=33
PL/SQL procedure successfully completed.
ASCII values for a-z : 97-122
ASCII values for A-Z: 65-90
ASCII values for 0-9: 48-57
No comments:
Post a Comment