begin
declare temp_num int;
declare chn_str varchar(10);
declare num_str varchar(20);
declare res_year varchar(20);
declare i int;
declare j int;
set chn_str = '〇一二三四五六七八九';
set temp_num = num + 0;
set i = 1;
set res_year = '';
if temp_num >1000 or (temp_num > 0 and temp_num < 10) then
set num_str = temp_num;
begin
while i <= length(num_str) do
set j = substring(num_str from i for 1)+1;
set res_year = concat(res_year,substring(chn_str from j for 1));
set i = i+1;
end while;
end;
end if;
if temp_num = 10 then
set num_str = temp_num;
set res_year = '十';
end if;
if temp_num > 10 and temp_num < 20 then
set num_str = temp_num;
set j = substring(num_str from 2 for 1)+1;
set res_year = concat('十',substring(chn_str from j for 1));
end if;
if temp_num = 20 then
set num_str = temp_num;
set res_year = '二十';
end if;
if temp_num > 20 and temp_num < 30 then
set num_str = temp_num;
set j = substring(num_str from 2 for 1)+1;
set res_year = concat('二十',substring(chn_str from j for 1));
end if;
if temp_num = 30 then
set num_str = temp_num;
set res_year = '三十';
end if;
if temp_num = 31 then
set num_str = temp_num;
set j = substring(num_str from 2 for 1)+1;
set res_year = concat('三十',substring(chn_str from j for 1));
end if;
return res_year;
end
MySQL 获取农历年函数
最新推荐文章于 2021-02-27 13:07:34 发布