Create definer = 'root' @ '%' function 'SP _ cn' (n_lowermoney decimal (200) returns varchar () charset utf8
Begin
Declare v_lowerstr varchar (200 );
Declare v_upperpart varchar (200 );
Declare v_upperstr varchar (200 );
Declare I _ I int;
Set v_lowerstr = ltrim (rtrim (round (n_lowermoney, 2 )));
Set I _ I = 1;
Set v_upperstr = '';
While (I _ I <= char_length (v_lowerstr) do
Set v_upperpart = Concat (Case substring (v_lowerstr, char_length (v_lowerstr)-I _ I + 1,1)
When '. 'then' yuan'
When '0' then '0'
When '1' then 'yi'
When '2' then 'er'
When '3' then 'san'
When '4' then'
When '5' then' Wu'
When '6' then 'l'
WHEN '7' then' THEN'
WHEN '8' then' THEN'
WHEN '9' then' THEN'
END,
Case I _ I
WHEN 1 THEN 'Min'
WHEN 2 THEN 'angular'
WHEN 3 then''
WHEN 4 then''
WHEN 5 THEN 'start'
WHEN 6 THEN 'hangzhou'
WHEN 7 THEN 'hangzhou'
WHEN 8 THEN 'wane'
WHEN 9 THEN 'start'
WHEN 10 THEN 'hangzhou'
WHEN 11 THEN 'hangzhou'
WHEN 12 THEN '100'
WHEN 13 THEN 'start'
WHEN 14 THEN 'hangzhou'
WHEN 15 THEN 'hangzhou'
WHEN 16 THEN 'wane'
ELSE''
END );
Set v_UpperStr = CONCAT (v_UpperPart, v_UpperStr );
Set I _ I = I _ I + 1;
End while;
Set v_UpperStr = REPLACE (v_UpperStr, 'zero restart', 'zero ');
Set v_UpperStr = REPLACE (v_UpperStr, '0', '0 ');
Set v_UpperStr = REPLACE (v_UpperStr, '0', '0 ');
Set v_UpperStr = REPLACE (v_UpperStr, 'zero zero 0', 'zero ');
Set v_UpperStr = REPLACE (v_UpperStr, '0', '0 ');
Set v_UpperStr = REPLACE (v_UpperStr, 'zero-angle and zero-point', 'integer ');
Set v_UpperStr = REPLACE (v_UpperStr, '0 point', 'Integral ');
Set v_UpperStr = REPLACE (v_UpperStr, '0', '0 ');
Set v_UpperStr = REPLACE (v_UpperStr, '100, 0 billion, 0 thousand, RMB ');
Set v_UpperStr = REPLACE (v_UpperStr, '100 million RMB 0 thousand ', '100 billion RMB ');
Set v_UpperStr = REPLACE (v_UpperStr, '1970, 0001 ');
Set v_UpperStr = REPLACE (v_UpperStr, '000000', '000000 ');
Set v_UpperStr = REPLACE (v_UpperStr, '10 thousand yuan ', '10 thousand yuan ');
Set v_UpperStr = REPLACE (v_UpperStr, '20140901', '661 ');
Set v_UpperStr = REPLACE (v_UpperStr, '20140901', 'wan ');
Set v_UpperStr = REPLACE (v_UpperStr, '0 meta', 'meta ');
Set v_UpperStr = REPLACE (v_UpperStr, '0', '0 ');
If ('meta' = substring (v_UpperStr, 1, 1) then
Set v_UpperStr = substring (v_UpperStr, 2, (char_length (v_UpperStr)-1 ));
End if;
If ('0' = substring (v_UpperStr, 1, 1) then
Set v_UpperStr = substring (v_UpperStr, 2, (char_length (v_UpperStr)-1 ));
End if;
If ('angular '= substring (v_UpperStr, 1, 1) then
Set v_UpperStr = substring (v_UpperStr, 2, (char_length (v_UpperStr)-1 ));
End if;
If ('bin' = substring (v_UpperStr,) then
Set v_UpperStr = substring (v_UpperStr, 2, (char_length (v_UpperStr)-1 ));
End if;
If ('Integral '= substring (v_UpperStr,) then
Set v_UpperStr = 'zero yuan ';
End if;
Return v_UpperStr;
END;