ASCII in oracle, masking power on

netbanker發表於2009-02-05

ASCII: function converts a single character to its corresponding ASCII code.

[@more@]

CHARASCIICHARASCIICHARASCII
Null 0+43 V 86
Start of Heading 1 ' 44W 87
Start of Text2 -45X 88
End of Text 3 . 46Y89
End of Transmission 4 /47 Z 90
Enquiry 5 0 48 [ 91
Acknowledge 6 1 49 / 92
Bell 72 50 ]93
Backspace 8 3 51 ^ 94
Tab 94 52_95
Line Feed 10 5 53` 96
Vertical Tab 11 6 54 a97
Form Feed127 55b 98
Carriage Return 13 856 c 99
Shift Out 14 9 57d100
Shift In 15:58 e 101
Data Link Escape 16 ; 59f 102
Device Control 117 <60 g 103
Device Control 218 = 61h 104
Device Control 3 19 > 62i 105
Device Control 420 ? 63j106
Negative Acknowledge 21 @ 64 k 107
Synchronous Idle22 A65 l108
End Transmission Block 23 B 66 m109
Cancel 24C 67 n 110
End of Medium 25D68 o111
Substitute (EOF) 26E 69p 112
Escape 27 F 70 q113
File Separator 28 G 71 r 114
Group Separator 29H72 s 115
Record Separator 30I 73 t 116
Unit Separator 31 J74u 117
Space32K 75 v118
! 33 L76w 119
"34M77 x120
#35N 78 y 121
$ 36 O79z122
% 37P80{123
& 38 Q 81 |124
' 39 R 82} 125
(40 S 83~126
(40 S 83~126
)41 T 84
*42 U 85

SQL> select ASCII('a') from dual;

ASCII('A')
----------
97

SQL> select ASCII('Account') from dual;

ASCII('ACCOUNT')
----------------
65

SQL> select ASCII('A') from dual;

ASCII('A')
----------
65

now the fun part:

SQL> select
2 REPLACE
3 (CAST(ASCII(SUBSTR('abcdefghijklm' ,3 , 1)) AS CHAR(3))||
4 CAST(ASCII(SUBSTR('abcdefghijklm' ,4 , 1)) AS CHAR(3))||
CAST(ASCII(SUBSTR('abcdefghijklm' ,5 , 1)) AS CHAR(3))||
5 6 CAST(ASCII(SUBSTR('abcdefghijklm' , 6 , 1)) AS CHAR(3))||
CAST(ASCII(SUBSTR('abcdefghijklm' , 7 , 1)) AS CHAR(3))||
7 8 CAST(ASCII(SUBSTR('abcdefghijklm' , 8 , 1)) AS CHAR(3))||
9 CAST(ASCII(SUBSTR('abcdefghijklm' , 9 , 1)) AS CHAR(3))||
10 CAST(ASCII(SUBSTR('abcdefghijklm' , 10 , 1)) AS CHAR(3))||
11 CAST(ASCII(SUBSTR('abcdefghijklm' , 11 , 1)) AS CHAR(3))||
12 CAST(ASCII(SUBSTR('abcdefghijklm' , 12 , 1)) AS CHAR(3))
13 ,' ' ,'')
14 from dual;

REPLACE(CAST(ASCII(SUBSTR('ABC
------------------------------
99100101102103104105106107108

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/67/viewspace-1016742/,如需轉載,請註明出處,否則將追究法律責任。

相關文章