通过oracle的NLSSORT函数对汉字按照拼音排序,然后根据汉字的区间返回对应的首字母. 效果1,获取拼音简码: 效果2,获取姓名首字母: 创建函数: /* 获取拼音简码函数 */ CREATE OR REPLACE FUNCTION GET_PYJM (P_NAME IN VARCHAR2) RETURN VARCHAR2 AS V_COMPARE ); V_RETURN ); BEGIN DECLARE FUNCTION F_NLSSORT (P_WORD IN VARCHAR2) RE
--创建取汉字首字母函数(第三版) create function [dbo].[f_getpy_V3] ( ) ) ) as begin ),) ,@len = len(@col),@sql = '' while @cyc <= @len begin ) as varbinary) ),ecode ),letter )) insert into @maco select 0XB0A1,0XB0C4,'A' union all select 0XB0C5,0XB2C0,'B' union all
DELIMITER $$ DROP FUNCTION IF EXISTS `Fun_GetPY`$$ CREATE FUNCTION `HIS`.`Fun_GetPY` (in_string VARCHAR(21845)) RETURNS VARCHAR(21845) CHARSET utf8 BEGIN #截取字符串,每次做截取后的字符串存放在该变量中,初始为函数参数in_string值 DECLARE tmp_str VARCHAR(21845) CHARSET gbk DEFAULT ''
从网络上收刮了一些,以备后用 create function fun_getPY(@str nvarchar()) returns nvarchar() as begin declare @word nchar(),@PY nvarchar() set @PY='' begin ) --如果非汉字字符,返回原字符 and + then ( PY from ( select 'A' as PY,N'驁' as word union all select 'B',N'簿' union all sel
CREATE function [dbo].[Func_GetPY](@str nvarchar(4000))returns nvarchar(4000)asbegin set @str=RTRIM(@str) declare @word nchar(1),@PY nvarchar(4000) set @PY='' while len(@str)>0 begin --处理常用多音字 if len(@str)>=2 begin if left(@str,2)='重庆' begin set @PY