logo 西林@生存 - 骑猪闯天下!
语言排序之函数篇:NLSSORT
2006-10-17 16:55:00 By:xling

先见:http://xling.blueidea.com/archives/2006/2922.shtml

在那篇日志里,是用

ALTER SESSION SET NLS_SORT = '...'

的方法来指定的,但是它会影响到整个会话(SESSION).

刚才去www.oracle.com.cn看了看,发现一个函数:

NLSSORT,可以用来进行语言排序,且不影响当前会话.

The NLSSORT or National Language Sort function allows you to specify a sort sequence and a string to be sorted and returns a sorted string. If you don't specify the 'NLS_SORT = ' sort string parameters, the sort will default to the value set for your session.
Both char and nlsparam can be any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The string returned is of RAW datatype.

The value of 'nlsparams' can have the form

'NLS_SORT = sort'
where sort is a linguistic sort sequence or BINARY. If you omit 'nlsparams', this function uses the default sort sequence for your session. If you specify BINARY, this function returns char.

Note:  This function does not support CLOB data directly. However, CLOBs can be passed in as arguments through implicit data conversion.

The keyword BINARY can be used if desired. Essentially, BINARY indicates a pass through and the original value of the string to be sorted is returned.

The NLSSORT function can be used in WHERE and ORDER BY clauses to allow linguistic rather than binary based sorts. The ORACLE7 Server Application Developer's Guide provides some examples of how the NLSSORT function can be used.

例:

拼音
SELECT * FROM TEAM ORDER BY NLSSORT(队名,'NLS_SORT = SCHINESE_PINYIN_M')
笔划
SELECT * FROM TEAM ORDER BY NLSSORT(队名,'NLS_SORT = SCHINESE_STROKE_M')
部首
SELECT * FROM TEAM ORDER BY NLSSORT(队名,'NLS_SORT = SCHINESE_RADICAL_M')


转我的贴,写你的名,是一种可耻的行为!请不要让我BS你!
阅读全文 | 回复(0) | 引用通告 | 编辑

发表评论:

    密码:
    主页:
    标题:
    页面数据正在载入...
<<  < 2006 - 10 >  >>
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Placard
1,長江後浪推前浪,前浪死在沙灘上!
2,有了钱的男人,才是真正的男人...
3,不要以为把你的小JJ埋进土里,你就rape了整个地球;不要以为把你的小JJ朝向天空,你就rape了整个宇宙!
Logon System
Search
Info about this blog
Others
myDream
bxna 京ICP备05002321号