declare v_pinyin VARCHAR(200);
#替换各种特殊符号
select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(replace(replace(replace(v_hanzi,
'A','A'),'B','B'),'C','C'),'D','D'),'E','E'),'F','F'),'G','G'),'H','H'),
'I','I'),'J','J'),'K','K'),'L','L'),'M','M'),'N','N'),'O','O'),'P','P'),
'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;
if v_type = '1' then #简拼
set @V_NAME_TEMP=V_NAME_TEMP;
set @strResult=null;
call Prc_Get_Pym(@V_NAME_TEMP, @strResult);
elseif v_type = '2' then #尾全拼
#判断结尾字符是否是中文
select ltrim(rtrim(substr(V_NAME_TEMP, char_length(V_NAME_TEMP), char_length(V_NAME_TEMP))))
into v_subb
from dual;
if v_subb is null then #如果不是中文则直接生成开口码
set @V_NAME_TEMP=V_NAME_TEMP;
set @strResult=null;
call Prc_Get_Pym(@V_NAME_TEMP, @strResult);
else
select substr(V_NAME_TEMP, 1, char_length(V_NAME_TEMP)-1) into strHanzi from dual;
set @strHanzi=strHanzi;
set @strTemp1=null;
call Prc_Get_Pym(@strHanzi, @strTemp1);
select substr(V_NAME_TEMP, char_length(V_NAME_TEMP), char_length(V_NAME_TEMP)) into strHanzi from dual;
set @strHanzi=strHanzi;
set @strTemp=null;
call Sp_Pinyin(@strHanzi, @strTemp);
select substr(@strTemp, 1, char_length(@strTemp) - 1) into @strResult from dual;
select concat_ws('',@strTemp1,@strResult) into @strResult from dual;
end if;
elseif v_type = '3' then #首全拼
#判断开头字符是否是中文
select ltrim(rtrim(substr(V_NAME_TEMP, 1, 1))) into v_subb from dual;
if v_subb is null then #如果不是中文则直接生成开口码
set @V_NAME_TEMP=V_NAME_TEMP;
set @strResult=null;
call Prc_Get_Pym(@V_NAME_TEMP, @strResult);
else
select substr(V_NAME_TEMP, 2, char_length(V_NAME_TEMP)) into strHanzi from dual;
set @strHanzi=strHanzi;
set @strResult=null;
call Prc_Get_Pym(@strHanzi, @strResult);
select substr(V_NAME_TEMP, 1, 1) into strHanzi from dual;
set @strHanzi=strHanzi;
set @strTemp=null;
call Sp_Pinyin(@strHanzi, @strTemp);
select concat_ws('',substr(@strTemp, 1, char_length(@strTemp) - 1),@strResult) into @strResult from dual;
end if;
end if;
set v_pinyin=UPPER(@strResult);
return v_pinyin;
end;
$$
delimiter ;
4. 使用方法/案例

文章插图
推荐阅读
- 汉字演变的过程顺序是什么样的 汉字演变的过程顺序正确的是
- 50元也能把智能家居玩出花样!买这几款就能实现全屋智能!
- 就这样人类最早的文字之一汉字诞生了?人类最早的文字之一是什么创造的汉字
- 厨房怎么样收纳,才能实现台面无物?
- 用Stream实现mysql的groupBy, sum Case when 语法
- 卫星|华为Mate 50将先于iPhone 14实现卫星通信:率先接入北斗卫星
- 发现衣柜中间留空一排,仅简单一步,实现2倍收纳还省了床头柜!
- 史上那些“一字抵千”言的故事 关于汉字的故事
- Arm|X86、ARM为何成主流CPU生态?专家:砸钱实现其他标准规范源代码
- 实现将近10℃的降温!顶层学他家这样去刷,防水堵漏、隔热效果佳
