我想编写一个程序,根据表格中的数据,用文本替换每个特定的字母。
create table jap (
alpha varchar2(1),
conv varchar2(5)
);
insert into jap(alpha,conv) values ( 'A' , 'ka' );
insert into jap(alpha,conv) values ( 'B' , 'tu' );
insert into jap(alpha,conv) values ( 'C' , 'mi' );
insert into jap(alpha,conv) values ( 'D' , 'te' );
insert into jap(alpha,conv) values ( 'E' , 'ku' );
insert into jap(alpha,conv) values ( 'F' , 'lu' );
insert into jap(alpha,conv) values ( 'G' , 'ji' );
例如,输入DEC
应该会产生输出tekumi
。
答案 0 :(得分:5)
试试这个:
SELECT xmlagg(xmlelement(e, conv)
ORDER BY l).extract('//text()') .getstringval()
FROM
(SELECT DISTINCT LEVEL l,
substr('DEC', LEVEL, 1) letter
FROM dual CONNECT BY LEVEL <= length('DEC'))
INNER JOIN jap ON alpha = letter
ORDER BY l ;
Here是一个小提琴