论坛首页 综合技术论坛

转换 字符 全角半角

浏览 1983 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-07-13   最后修改:2009-07-16

Oracle数据库:

Select TO_MULTI_BYTE('A') from dual;

Select TO_SINGLE_BYTE ('A') from dual;

其他数据库:

CREATE OR REPLACE PROCEDURE p_fulltohalf(instr  IN VARCHAR2,
                                         outstr OUT VARCHAR2) IS
  v_i INTEGER;

BEGIN

  v_i    := 1;
  outstr := '';

  WHILE v_i <= length(instr) LOOP
  
    IF ascii(substr(instr, v_i, 1)) > 41856 AND
       ascii(substr(instr, v_i, 1)) < 41856 + 128 THEN
    
      outstr := outstr || chr(ascii(substr(instr, v_i, 1)) - 41856);
    
    ELSE
    
      outstr := outstr || substr(instr, v_i, 1);
    
    END IF;
  
    v_i := v_i + 1;
  
  END LOOP;

END p_fulltohalf;

  --测试脚本

DECLARE

str VARCHAR2(110);

BEGIN

p_fulltohalf('夺夺ddfdfwfew((dfdfdf0$2d#!@@sdf)9', str); dbms_output.put_line(str);

END;

  

论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics