潇湘夜雨

欢迎来到潇湘夜雨>>   | 首页 资源中心 | Others | TOMCAT | 太极拳 | 杂感 | SQL | ITPUB论坛

Reverse a multi-byte string

发表人:hmxxyy | 发表时间: 2006年五月11日, 14:16

reverse() reverses a single byte string but it does not work well with multi-byte characters

SQL> select reverse('abc') from dual;
REVERS
------
cba

SQL> exec :mystr := '国中cba';
1 SELECT max(replace(SYS_CONNECT_BY_PATH (c, '/'), '/')) keep (dense_rank last order by level)
2 FROM (SELECT LEVEL lvl, SUBSTR (:mystr, LEVEL, 1) c
3 FROM (SELECT LENGTH (:mystr) len
4 FROM DUAL) x
5 CONNECT BY LEVEL <= x.len
6 ORDER BY 1 DESC)
7* CONNECT BY PRIOR lvl = lvl + 1

MAX(REPLACE(SYS_CONNECT_BY_PATH(C,'/'),'/'))KEEP(DENSE_RANKLASTORDERBYLEVEL)
----------------------------------------------------------------------------
abc中国

发表评论

标题

在此添加评论

称呼

邮箱地址(可选)

个人主页(可选)




Valid XHTML 1.0 Strict and CSS. Powered by pLog
Design by Blog.lvwo.com