create or replace function f_henry_GetStringLength(pv_String in varchar2) return integer is
Result integer;
i number;
begin
Result:=0;
if length(pv_String)=0 then
return(Result);
end if;
for i in 1 .. length(pv_String) loop
if ascii(substr(pv_String,i,1))<256 then
Result:=Result+1;
else
Result:=Result+2;
end if;
end loop;
return(Result);
end f_henry_GetStringLength;
/*************************以下是测试***************************/
SQL> select length('啊$@oii发大幅') from dual;
LENGTH('啊$@OII发大幅')
-----------------------
9
SQL> select f_henry_GetStringLength('啊$@oii发大幅') from dual;
F_HENRY_GETSTRINGLENGTH('啊$@O
------------------------------
13
……