Show pageOld revisionsBacklinksExport to PDFFold/unfold allBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== pears.CommaThousandsDec ====== <WRAP center round info> Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. </WRAP> ===== Original SQL ===== <code sql> create function "pears"."CommaThousandsDec"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "d" double ) returns char(40) begin declare "rv" char(40); declare "s" char(20); declare "t" char(20); declare "i" integer; declare "c" char(1); declare "fract" double; set "fract" = "abs"("remainder"("d",1)); if "fract" = 0 then set "fract" = null end if; if "d" is null then return null end if; if "d" < 0 then set "d" = "abs"("d"); set "c" = '-' else set "c" = '' end if; set "rv" = ''; set "s" = "trim"("str"("d",20,0)); set "i" = -1; "lbl": loop set "t" = "substr"("s","i",-3); if "t" = '' then leave "lbl" end if; if "rv" <> '' then set "rv" = ','+"rv" end if; set "rv" = "t"+"rv"; set "i" = "i"-3 end loop "lbl"; return("c"+"rv"+"string"("fract")) end </code> database/functions/pears_commathousandsdec.txt Last modified: 2026/08/07 19:24by 127.0.0.1