====== pears.GetPersonAddressOnLine ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."GetPersonAddressOnLine"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "reqpersonid" char(20) )
returns char(250)
begin
declare "AddressOnLine" char(250);
declare "addr1" char(40);
declare "addr2" char(40);
declare "addr3" char(40);
declare "town" char(30);
declare "county" char(30);
declare "country" char(30);
declare "postcode" char(30);
select "person"."addr1","person"."addr2","person"."addr3","person"."town","person"."county","person"."country","person"."postcode" into "addr1",
"addr2","addr3","town","county","country","postcode" from "person"
where "personid" = "reqpersonid";
if "isnull"("addr1",'') <> '' then set "AddressOnLine" = "AddressOnLine" || "trim"("addr1")
end if;
if "isnull"("AddressOnLine",'') <> '' and "isnull"("addr2",'') <> '' then set "AddressOnLine" = "AddressOnLine" || ', '
end if;
if "isnull"("addr2",'') <> '' then set "AddressOnLine" = "AddressOnLine" || "trim"("addr2")
end if;
if "isnull"("AddressOnLine",'') <> '' and "isnull"("addr3",'') <> '' then set "AddressOnLine" = "AddressOnLine" || ', '
end if;
if "isnull"("addr3",'') <> '' then set "AddressOnLine" = "AddressOnLine" || "trim"("addr3")
end if;
if "isnull"("AddressOnLine",'') <> '' and "isnull"("town",'') <> '' then set "AddressOnLine" = "AddressOnLine" || ', '
end if;
if "isnull"("town",'') <> '' then set "AddressOnLine" = "AddressOnLine" || "trim"("town")
end if;
if "isnull"("AddressOnLine",'') <> '' and "isnull"("county",'') <> '' then set "AddressOnLine" = "AddressOnLine" || ', '
end if;
if "isnull"("county",'') <> '' then set "AddressOnLine" = "AddressOnLine" || "trim"("county")
end if;
if "isnull"("AddressOnLine",'') <> '' and "isnull"("country",'') <> '' then set "AddressOnLine" = "AddressOnLine" || ', '
end if;
if "isnull"("country",'') <> '' then set "AddressOnLine" = "AddressOnLine" || "trim"("country")
end if;
if "isnull"("AddressOnLine",'') <> '' and "isnull"("postcode",'') <> '' then set "AddressOnLine" = "AddressOnLine" || ' '
end if;
if "isnull"("postcode",'') <> '' then set "AddressOnLine" = "AddressOnLine" || "trim"("postcode")
end if;
return "AddressOnLine"
end