DECLARE
CnyStr varchar2 (50) :=‘’;
CnyChar varchar2 (50) := ‘’;
num_char VARCHAR2 (128) := ‘〇一二三四五六七八九’;
part VARCHAR2 (128);
flag NUMBER := 0;
BEGIN
if lengthb(num)=2 then
if num=10 then
RETURN ‘十’ ;
else
FOR i IN 1 … 2 LOOP
part := substring(num, i, 1);
if i=1 and part!=1 then
CnyChar := substring(num_char, part + 1, 1) ||‘十’;
elsif i=1 and part=1 then
CnyChar :=‘十’;
else
CASE part
WHEN ‘0’ THEN
IF flag = 0 THEN
CnyChar := ‘〇’;
else
CnyChar := ‘十’;
end IF;
ELSE
CnyChar := substring(num_char, part + 1, 1);
flag := 1;
END CASE;
end if;
CnyStr := CnyStr || CnyChar;
END LOOP;
RETURN CnyStr ;
end if;
else
FOR i IN 1 … 4 LOOP
part := substr(num, i, 1);
CASE part
WHEN ‘0’ THEN
IF flag = 0 THEN
CnyChar := ‘〇’;
else
CnyChar := ‘〇’;
end IF;
ELSE
CnyChar := substring(num_char, part + 1, 1);
flag := 1;
END CASE;
CnyStr := CnyStr || CnyChar;
END LOOP;
return CnyStr;
end if;
END