create or replace function ftreadtbaht(ai_amount in number ) return varchar2 is ls_ans1 varchar2(200); ls_money1 varchar2(200); ls_money2 varchar2(200); ls_money3 varchar2(200); ls_pre varchar2(100); ls_moneystr varchar2(100); ls_curr_name varchar2(10); ls_curr_sub_name varchar2(10); li_strlength number; li_counter1 number; li_stang number; ls_decimal varchar2(200); begin if (ls_curr_name is null) or (ls_curr_name = '') then ls_curr_name := 'ºÒ·'; end if; if (ls_curr_sub_name is null) or (ls_curr_sub_name = '') then ls_curr_sub_name := 'ʵҧ¤ì'; end if; li_strlength := nvl(length(to_char(ai_amount)), 0); if substr(to_char(ai_amount),li_strlength-1,1) = '.' then ls_money1 := to_char(ai_amount)||'0'; else ls_money1 := to_char(ai_amount); end if; li_counter1 := 1; ls_ans1 := ''; li_stang := 0; loop exit when nvl(length(ls_money1), 0) = 0; li_strlength := nvl(length(ls_money1), 0); ls_money2 := substr(ls_money1,li_strlength,1); if li_strlength <> 1 then ls_money3 := substr(ls_money1,li_strlength - 1,1); end if; if ls_money2 = '0' then ls_moneystr := ''; else if ls_money2 = '1' then ls_moneystr := '˹Öè§'; if li_counter1 = 1 then --If ls_money3 <> '0' And li_strlength > 1 Then if li_strlength > 1 then ls_moneystr := 'àÍç´'; end if; else if li_counter1 = 2 then ls_moneystr := ''; end if; end if; else if ls_money2 = '2' then if li_counter1 = 2 then ls_moneystr := 'ÂÕè'; else ls_moneystr := 'Êͧ'; end if; else if ls_money2 = '3' then ls_moneystr := 'ÊÒÁ'; else if ls_money2 = '4' then ls_moneystr := 'ÊÕè'; else if ls_money2 = '5' then ls_moneystr := 'ËéÒ'; else if ls_money2 = '6' then ls_moneystr := 'Ë¡'; else if ls_money2 = '7' then ls_moneystr := 'à¨ç´'; else if ls_money2 = '8' then ls_moneystr := 'á»´'; else if ls_money2 = '9' then ls_moneystr := 'à¡éÒ'; else ls_moneystr := ''; end if; end if; end if; end if; end if; end if; end if; end if; end if; end if; ls_pre := ''; if li_counter1 = 1 then ls_pre := ''; else if li_counter1 = 2 then if ls_money2 <> '0' then ls_pre := 'ÊÔº'; end if; else if li_counter1 = 3 then if ls_money2 <> '0' and ls_money2 <> '.' then ls_pre := 'ÃéÍÂ'; end if; else if li_counter1 = 4 then if ls_money2 <> '0' then ls_pre := '¾Ñ¹'; end if; else if li_counter1 = 5 then if ls_money2 <> '0' then ls_pre := 'ËÁ×è¹'; end if; else if li_counter1 = 6 then if ls_money2 <> '0' then ls_pre := 'áʹ'; end if; end if; end if; end if; end if; end if; end if; ls_money1 := substr(ls_money1,1,li_strlength - 1); ls_ans1 := ls_moneystr||ls_pre||ls_ans1; if li_counter1 = 6 then li_counter1 := 1; if li_strlength >1 then ls_ans1 := 'ÅéÒ¹'||ls_ans1; end if; else if ls_money2 = '.' then li_stang := 1; li_counter1 := 1; ls_decimal := ls_ans1; if ls_ans1 <> '' then if li_strlength > 2 then ls_ans1 := ltrim(ls_curr_name)||ls_ans1||ltrim(ls_curr_sub_name); else if li_strlength = 2 then if ls_money3 <> '0' then ls_ans1 := ltrim(ls_curr_name)||ls_ans1||ltrim(ls_curr_sub_name); else ls_ans1 := ls_ans1||ltrim(ls_curr_sub_name); end if; else ls_ans1 := ls_ans1||ltrim(ls_curr_sub_name); end if; end if; else ls_ans1 := ltrim(ls_curr_name)||ls_decimal||ltrim(ls_curr_sub_name); end if; else li_counter1 := li_counter1 +1; end if; end if; end loop; if li_stang = 0 then return(ls_ans1||ltrim(ls_curr_name)||'¶éǹ'); else return(ls_ans1); end if; end ;