create or replace function ftreadtnum(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_amount number; li_strlength number; li_counter1 number; li_stang number; li_stangflag number; ls_decimal varchar2(200); begin --li_amount := trunc( ai_amount , 2 ); li_amount := ai_amount; ls_curr_name := '???'; ls_curr_sub_name := ''; li_strlength := nvl(length(to_char(li_amount)), 0); if substr(to_char(li_amount),li_strlength-1,1) = '.' then ls_money1 := to_char(li_amount)||'0'; else ls_money1 := to_char(li_amount); end if; if instr( to_char( li_amount ) , '.' ) > 0 then li_stangflag := 1; else li_stangflag := 0; 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 if li_stangflag = 1 then ls_moneystr := '?????'; else ls_moneystr := ''; end if; else if ls_money2 = '1' then ls_moneystr := '????'; if li_counter1 = 1 then if ls_money3 <> '0' then --If li_strlength > 1 Then if li_stangflag = 0 then ls_moneystr := '????'; end if; end if; else if li_counter1 = 2 then if li_stangflag = 0 then ls_moneystr := ''; end if; end if; end if; else if ls_money2 = '2' then if li_counter1 = 2 then if li_stangflag = 0 then ls_moneystr := '???'; else ls_moneystr := '??' ; end if; 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 if li_stangflag = 0 then ls_pre := '???'; else ls_pre := ''; end if; end if; else if li_counter1 = 3 then if ls_money2 <> '0' and ls_money2 <> '.' and li_stangflag = 0 then ls_pre := '????'; end if; else if li_counter1 = 4 and li_stangflag = 0 then if ls_money2 <> '0' then ls_pre := '???'; end if; else if li_counter1 = 5 and li_stangflag = 0 then if ls_money2 <> '0' then ls_pre := '?????'; end if; else if li_counter1 = 6 and li_stangflag = 0 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 and li_stangflag = 0 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); --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; if ls_money2 = '.' then li_stangflag := 0; end if; end loop; return(ls_ans1); end ;