先见: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')
|