function lcw_get_money(money in number) return varchar2 is
c_money VARCHAR2(12);
b_string VARCHAR2(80);
m_string VARCHAR2(60) := '分角圆拾佰仟万拾佰仟亿';
n_string VARCHAR2(40) := '壹贰叁肆伍陆柒捌玖';
n CHAR;
len NUMBER(10);
i NUMBER(10);
tmp NUMBER(12);
is_zj BOOLEAN;
z_count NUMBER(10);
l_money NUMBER;
l_money1 NUMBER;
l_sign VARCHAR2(10);
BEGIN
l_money1 := to_number(money);
l_money := abs(money);
IF l_money1 < 0 THEN
l_sign := '负';
ELSE
l_sign := '';
END IF;
tmp := round(l_money, 2) * 100;
c_money := rtrim(ltrim(to_char(tmp, '999999999999')));
len := length(c_money);
is_zj := TRUE;
z_count := 0;
i := 0;
WHILE i < len LOOP
i := i + 1;
n := substr(c_money, i, 1);
IF n = '0' THEN
IF len – i = 6 OR len – i = 2 OR len = i THEN
IF is_zj THEN
b_string := substr(b_string, 1, length(b_string) – 1);
is_zj := FALSE;
END IF;
IF len – i = 6 THEN
b_string := b_string || '万';
END IF;
IF len – i = 2 THEN
b_string := b_string || '圆';
END IF;
IF len = i THEN
b_string := b_string || '整';
END IF;
z_count := 0;
ELSE
IF z_count = 0 THEN
b_string := b_string || '零';
is_zj := TRUE;
END IF;
z_count := z_count + 1;
END IF;
ELSE
b_string := b_string || substr(n_string, to_number(n), 1) ||
substr(m_string, len – i + 1, 1);
z_count := 0;
is_zj := FALSE;
END IF;
END LOOP;
b_string := l_sign || b_string;
RETURN b_string;
EXCEPTION
WHEN OTHERS THEN
RETURN(SQLERRM);
END;