*問題:
User輸入Excel資料的時候,會輸入中文的「一、二、三、四、五、六、七、八、九」
Parsing到資料庫時,為了確保資料跟User輸入的一樣,也是以中文儲存
但在下載時,就會遇到排序有問題的情況
例如:三會排在二前面
ORDER |
---|
一 |
三 |
二 |
*解決方式
使用Oracle Function:translate
WITH temp AS
(
SELECT '一' AS ch
FROM dual
UNION ALL
SELECT '二' AS ch
FROM dual
UNION ALL
SELECT '三' AS ch
FROM dual
UNION ALL
SELECT '四' AS ch
FROM dual
UNION ALL
SELECT '五' AS ch
FROM dual
UNION ALL
SELECT '六' AS ch
FROM dual
UNION ALL
SELECT '七' AS ch
FROM dual
UNION ALL
SELECT '八' AS ch
FROM dual
UNION ALL
SELECT '九' AS ch
FROM dual
)
SELECT *
FROM temp
ORDER BY translate(combination_seq, '一二三四五六七八九', '123456789');
*缺點
只適用1~9以內的中文字,若為十以上,則要另外處理,很麻煩