'Q','Q'),'R','R'),'S','S'),'T','T'),'U','U'),'V','V'),'W','W'),'X','X'),
'Y','Y'),'Z','Z'),'+',''),'-',''),'*',''),'/',''),
'[',''),']',''),'{',''),'}',''),'(',''),')',''),
'<',''),'>',''),'《',''),'》',''),'(',''),')',''),'"',''),
'“',''),'”',''),'.',''),' 。',''),'-',''),'-',''),'/',''),
'/',''),'',''),' ',''),'1','一'),'2','二'),'3','三'),
'4','四'),'5','五'),'6','六'),'7','七'),'8','八'),'9','九'),'0','零') R3
into V_NAME_TEMP
from dual;
#循环获得字符串拼音码
myloop:loop
if V_NAME is null then
leave myloop;
end if;
select substr(V_NAME_TEMP, i, 1) into V_NAME_SIN from dual;
set i=i+1;
if V_NAME_SIN <> ' ' then
select count(*)
into v_counter1
from bst_wbjq
where bst_wbjq.charactor=v_name_sin;
if v_counter1 > 0 then
select WORD
into V_PINYIN_SIN
from bst_wbjq
where bst_wbjq.CHARACTOR=V_NAME_SIN
limit 1;
select concat_ws('',V_PINYIN_TEMP,V_PINYIN_SIN)
into V_PINYIN_TEMP
from dual;
end if;
end if;
select char_length(V_NAME) into j from dual;
if i > j then
leave myloop;
end if;
end loop;
#截取32位长度字符
if char_length(V_PINYIN_TEMP) > 32 then
select substr(V_PINYIN_TEMP, 1, 32) into V_PYM from dual;
else
select V_PINYIN_TEMP into V_PYM from dual;
end if;
end;
$$
delimiter ;
3.2. 创建存储过程:SP_PINYIN
-- procedure structure for SP_PINYIN
-- ----------------------------
delimiter $$
drop procedure if exists SP_PINYIN;
$$
create procedure SP_PINYIN(IN hanzi varchar(256),OUT pinyin varchar(256))
begin
declare aword varchar(200);
declare aresult varchar(200);
declare temp1 varchar(20);
declare len int default 0;
declare point int default 1;
declare charword varchar(20);
declare charlen int default 1;
#定义游标标志变量
declare done int default false;
#定义游标
declare cur_pinyin cursor for
select PY from TBL_PINYIN
where word=substr(aword, point, charlen);
#指定游标循环结束时的返回值
declare continue HANDLER for not found set done=true;
select ltrim(rtrim(hanzi)) into aword from dual;
select char_length(aword) into len from dual;
#<<LABEL1>>
while point <= len do
select '' into temp1 from dual;
select substr(aword, point, 1) into charword from dual;
if (charword is not null and charword != ' ') then
select concat_ws(' ',aresult,charword) into aresult from dual;
else
select 2 into charlen from dual;
end if;
#打开游标
open cur_pinyin;
#开始循环处理游标里的数据
read_loop:loop
#获得游标当前指向的一条数据
fetch cur_pinyin into temp1;
#判断游标的循环是否结束
if done then
leave read_loop;
end if;
end loop; #结束游标循环
#关闭游标
close cur_pinyin;
if (point = 1) then
set aresult = temp1;
else
select concat_ws(' ',aresult,temp1) into aresult from dual;
end if;
select point+charlen into point from dual;
end while;
#输出结果
select aresult into pinyin from dual;
end;
$$
delimiter ;
3.3. 创建函数:to_pinyin
-- function structure for to_pinyin
-- ----------------------------
delimiter $$
drop function if exists to_pinyin;
$$
create function to_pinyin(v_hanzi varchar(256),v_type int)
returns varchar(256)
begin
declare strTemp VARCHAR(200);
declare strResult VARCHAR(200);
declare strHanzi VARCHAR(200);
declare strTemp1 VARCHAR(200);
declare v_subb VARCHAR(100);
declare V_NAME_TEMP VARCHAR(200);
推荐阅读
- 汉字演变的过程顺序是什么样的 汉字演变的过程顺序正确的是
- 50元也能把智能家居玩出花样!买这几款就能实现全屋智能!
- 就这样人类最早的文字之一汉字诞生了?人类最早的文字之一是什么创造的汉字
- 厨房怎么样收纳,才能实现台面无物?
- 用Stream实现mysql的groupBy, sum Case when 语法
- 卫星|华为Mate 50将先于iPhone 14实现卫星通信:率先接入北斗卫星
- 发现衣柜中间留空一排,仅简单一步,实现2倍收纳还省了床头柜!
- 史上那些“一字抵千”言的故事 关于汉字的故事
- Arm|X86、ARM为何成主流CPU生态?专家:砸钱实现其他标准规范源代码
- 实现将近10℃的降温!顶层学他家这样去刷,防水堵漏、隔热效果佳
