日期:2014-05-17 浏览次数:20873 次
select chr(ascii('b') - 1) "value" from dual /* v - a 1 row selected. */ select chr(ascii('c') - 1) "value" from dual /* v - b 1 row selected. */ select chr(ascii('z') - 1) "value" from dual /* v - y 1 row selected. */
------解决方案--------------------
如果传为A-->前面没字母时怎么显示
------解决方案--------------------
查看范围 select ascii('a'), ascii('z'), ascii('A'), ascii('Z') from dual; /** ASCII('A') ASCII('Z') ASCII('A') ASCII('Z') 1 97 122 65 90 **/ select chr(97), chr(122), chr(65), chr(90) from dual; /** CHR(97) CHR(122) CHR(65) CHR(90) 1 a z A Z **/
------解决方案--------------------
--将b当作参数传入 select decode('b','a','z',chr(ascii('b')-1)) as vaule from dual
------解决方案--------------------
可以使用TRANSLATE()函数,轻松实现。
参考代码:
SELECT TRANSLATE(原始字符串, 'bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA', 'abcdefghijklmnopqrstuvwxyzaABCDEFGHIJKLMNOPQRSTUVWXYZ');
------解决方案--------------------
translate函数果然牛!!!
------解决方案--------------------
用catch case吧,很好的