oracle得到拼音函数

CREATE OR REPLACE FUNCTION fgetpy (v_str VARCHAR2)
   RETURN VARCHAR2
AS
   v_strlen   INT;
   v_return   VARCHAR2 (500);
   v_ii       INT;
   v_n        INT;
   v_c        VARCHAR2 (2);
   v_chn      VARCHAR2 (2);
   v_rc       VARCHAR2 (500);
/*************************************************************************
生成汉字拼音码的函数。 wallimn 2009-06-21
**************************************************************************/
BEGIN
   --dbms_output.put_line(v_str);
   v_rc := v_str;
   v_strlen := LENGTH (v_rc);
   v_return := ‘‘;
   v_ii := 0;

WHILE v_ii < v_strlen
   LOOP
      v_ii := v_ii + 1;
      v_n := 63;

SELECT SUBSTR (v_rc, v_ii, 1)
        INTO v_chn
        FROM DUAL;

SELECT v_n + MAX (rowsf)
        INTO v_n
        FROM (SELECT chn, ROWNUM rowsf
                FROM (SELECT   chn
                          FROM (SELECT ‘吖‘ chn
                                  FROM DUAL
                                UNION
                                SELECT ‘八‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘嚓‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘咑‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘妸‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘发‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘旮‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘铪‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘丌‘
                                  FROM DUAL              --because have no ‘i‘
                                UNION ALL
                                SELECT ‘丌‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘咔‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘垃‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘嘸‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘拏‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘噢‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘妑‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘七‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘呥‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘仨‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘他‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘屲‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘屲‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘屲‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘夕‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘丫‘
                                  FROM DUAL
                                UNION ALL
                                SELECT ‘帀‘
                                  FROM DUAL
                                UNION ALL
                                SELECT v_chn
                                  FROM DUAL) a
                      ORDER BY NLSSORT (chn, ‘NLS_SORT=SCHINESE_PINYIN_M‘)) c) b
       WHERE chn = v_chn;

v_c := CHR (v_n);

IF CHR (v_n) = ‘@‘
      THEN                                                      --英文直接返回
         v_c := v_chn;
      END IF;

v_return := v_return || v_c;
    v_return := lower(v_return);
   END LOOP;

RETURN v_return;
END fgetpy;

时间: 2024-10-10 20:17:27

oracle得到拼音函数的相关文章

Oracle 中 decode 函数用法

Oracle 中 decode 函数用法 含义解释:decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) 该函数的含义如下:IF 条件=值1 THEN RETURN(翻译值1)ELSIF 条件=值2 THEN RETURN(翻译值2) ......ELSIF 条件=值n THEN RETURN(翻译值n)ELSE RETURN(缺省值)END IFdecode(字段或字段的运算,值1,值2,值3) 这个函数运行的结果是,当字段或字段的运算的值等于值1时,该函数返回值

【转】oracle的substr函数的用法

[转]oracle的substr函数的用法 oracle的substr函数的用法 取得字符串中指定起始位置和长度的字符串   substr( string, start_position, [ length ] ) 如:     substr('This is a test', 6, 2)     would return 'is'     substr('This is a test', 6)     would return 'is a test'     substr('TechOnThe

Oracle之自定义函数

数据库中函数包含四个部分:声明.返回值.函数体和异常处理. --没有参数的函数 create or replace function get_user return varchar2 is v_user varchar2(50); begin select username into v_user from user_users; return v_user; end get_user; --测试 方法一 select get_user from dual; 方法二 SQL> var v_nam

oracle 内置函数(一)数值函数

oracle内置函数主要分为四类: 数值函数 字符函数 日期函数 转换函数 本分析数值函数: 一.四舍五入round round(double,m) double:我们要处理的小数. m: default:在不填写的情况下默认为0,也就是取整: m>0:四舍五入小数点后m位: m<0:四舍五入小数点前m位. example: 二.取整 ceil:向上取整 floor:向下取整 三.常用计算 1.abs:取绝对值  2.mod:取余(除取模)任意参数为null返回null 3.power:幂函数

Oracle时间日期函数

ORACLE日期时间函数大全 TO_DATE格式(以时间:2007-11-02   13:45:25为例)           Year:              yy two digits 两位年                显示值:07        yyy three digits 三位年                显示值:007        yyyy four digits 四位年                显示值:2007                    Month

Oracle集合操作函数:union、intersect、minus

[转]Oracle集合操作函数:union.intersect.minus 集合操作符专门用于合并多条select 语句的结果,包括:UNION, UNION ALL, INTERSECT, MINUS.当使用集合操作符时,必须确保不同查询的列个数和数据类型匹配. 集合操作符具有以下注意事项: 集合操作符不适用于LOB.VARRAY和嵌套表列. UNION.INTERSECT.MINUS操作符不使用于 LONG列. 如果选择列表中包含有表达式或者函数,那么必须为表达式或者函数定义列别名. 1.U

重写Oracle的wm_concat函数,自定义分隔符、排序

oracle中,wm_concat函数是一个聚合函数,和mysql中的group_concat函数类似,不过group_concat函数比较强大,可以定义分隔符和排序,当然所谓强大是相对的,这里假使我们不知道oracle中的over函数,也不知道listagg函数. 我们先来看看wm_concat函数能实现什么功能,通俗点==>列传行,如果不明白,请看下面截图(可以看到分隔符默认为','顺序也是杂乱的)          所以,接下来,我们开始重写wm_concat函数(需要注意和需要说明的地方

ORACLE日期时间函数大全

ORACLE日期时间函数大全    TO_DATE格式(以时间:2007-11-02   13:45:25为例) Year:              yy two digits 两位年                显示值:07        yyy three digits 三位年                显示值:007        yyyy four digits 四位年                显示值:2007 Month:              mm    numbe

Oracle中SYS_CONNECT_BY_PATH函数的妙用

在Oracle中,SYS_CONNECT_BY_PATH函数主要作用是可以把一个父节点下的所有子节点通过某个字符进行区分,然后连接在一个列中显示. AD: Oracle中SYS_CONNECT_BY_PATH函数是非常重要的函数,下面就为您介绍一个使用SYS_CONNECT_BY_PATH函数的例子,实例如下: create table test (a varchar2(10),b varchar2(10)); INSERT INTO TEST (A, B) VALUES ('1', '我');