oracle用逗号分隔符分割的字段,转换中文说明
2017-01-04 11:13
309 查看
经常碰到某些字段使用逗号等分隔符分割的配置,批量转换成中文说明比较麻烦。目前想到使用正则表达式匹配,总体思路如下
【1】 先由一行用正则表达式提取分割成多行。
【2】 再用参数表查询中文名
【3】 再合成一行
—参数中文说明表
select id,name from tab_mb
id name
501 很好
502 一般好
503 相当好
—测试数据
select ‘501,502,503’ as source_string from dual
with t1 as
(select ‘501,502,503’ as source_string from dual),
t2 as
(select regexp_substr(source_string, ‘[^,]+’, 1, rownum) need_string
from t1
connect by rownum <=
length(source_string) - length(replace(source_string, ‘,’, ”)) + 1),
t3 as
(select need_string,
(select name from tab_mb h where a.need_string = h.id) need_string_name
from t2 a)
select to_char(wmsys.wm_concat(need_string_name)) as source_2_need from t3
结果输出
source_2_need
很好,一般好,相当好
【1】 先由一行用正则表达式提取分割成多行。
【2】 再用参数表查询中文名
【3】 再合成一行
—参数中文说明表
select id,name from tab_mb
id name
501 很好
502 一般好
503 相当好
—测试数据
select ‘501,502,503’ as source_string from dual
with t1 as
(select ‘501,502,503’ as source_string from dual),
t2 as
(select regexp_substr(source_string, ‘[^,]+’, 1, rownum) need_string
from t1
connect by rownum <=
length(source_string) - length(replace(source_string, ‘,’, ”)) + 1),
t3 as
(select need_string,
(select name from tab_mb h where a.need_string = h.id) need_string_name
from t2 a)
select to_char(wmsys.wm_concat(need_string_name)) as source_2_need from t3
结果输出
source_2_need
很好,一般好,相当好
相关文章推荐
- [My Function]Oracle删除同一字段内 分隔符 分割 的相同内容
- MySQL逗号分割字段的行列转换
- Oracle把逗号分割的字符串转换为可放入in的条件语句的字符数列
- Oracle中把逗号分割的字符串转换为可放入in的条件语句的字符数列
- oracle中V$session 表中各个字段的中文说明
- Oracle把逗号分割的字符串转换为可放入in的条件语句的字符数列
- Oracle 查询库中所有表名、字段名、字段名说明,查询表的数据条数、表名、中文表名、
- Oracle把逗号分割的字符串转换为可放入in的条件语句的字符数列
- 把逗号分割的字符串转换为可放入in的条件语句的字符数列 Oracle
- Oracle 查询库中所有表名、字段名、字段名说明,查询表的数据条数、表名、中文表名、
- 如何取得一个表的所有字段名用逗号分割(SQLSERVER和ORACLE)
- Oracle把逗号分割的字符串转换为可放入in的条件语句的字符数列
- MySQL逗号分割字段的行列转换技巧
- MySQL逗号分割字段的行列转换技巧
- MySQL逗号分割字段的行列转换技巧
- MySQL逗号分割字段的行列转换技巧
- Oracle字段根据逗号分割查询数据
- MySQL逗号分割字段的行列转换技巧
- Oracle把逗号分割的字符串转换为可放入in的条件语句的字符数列
- MySQL逗号分割字段的行列转换技巧