Oracle数据库:
Select TO_MULTI_BYTE('AA') from dual;
Select TO_SINGLE_BYTE ('AA') 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;