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.FormatAddress ====== <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"."FormatAddress"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "name" char(100),in "addr1" char(50),in "addr2" char(50),in "addr3" char(50),in "town" char(50),in "county" char(50),in "country" char(50),in "postcode" char(50), in "Capitalise" smallint,in "Style" char(1) ) /* Set the seperator for block or line */ /* If capitalise option is set, capitalise town. */ /* Build Formatted Address */ returns char(300) begin declare "FormattedAddress" char(300);declare "Separator" char(2);declare "PrePostCodeSeparator" char(2);set "FormattedAddress" = ''; if "style" = 'B' then set "Separator" = "char"(13)+"char"(10); set "PrePostCodeSeparator" = "Separator" else set "Separator" = ', '; set "PrePostCodeSeparator" = ' ' end if; if "Capitalise" = 1 then set "town" = "upper"("Town") end if; if "isnull"("name",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "trim"("name") end if; if "isnull"("FormattedAddress",'') <> '' and "isnull"("addr1",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "Separator" end if; if "isnull"("addr1",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "trim"("addr1") end if; if "isnull"("FormattedAddress",'') <> '' and "isnull"("addr2",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "Separator" end if; if "isnull"("addr2",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "trim"("addr2") end if; if "isnull"("FormattedAddress",'') <> '' and "isnull"("addr3",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "Separator" end if; if "isnull"("addr3",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "trim"("addr3") end if; if "isnull"("FormattedAddress",'') <> '' and "isnull"("town",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "Separator" end if; if "isnull"("town",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "trim"("town") end if; if "isnull"("FormattedAddress",'') <> '' and "isnull"("county",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "Separator" end if; if "isnull"("county",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "trim"("county") end if; if "isnull"("FormattedAddress",'') <> '' and "isnull"("country",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "Separator" end if; if "isnull"("country",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "trim"("country") end if; if "isnull"("FormattedAddress",'') <> '' and "isnull"("postcode",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "PrePostCodeSeparator" end if; if "isnull"("postcode",'') <> '' then set "FormattedAddress" = "FormattedAddress" || "trim"("postcode") end if; return "FormattedAddress" end </code> database/functions/pears_formataddress.txt Last modified: 2026/08/07 19:24by 127.0.0.1