====== pears.GetCompanyAddressOnLine ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."GetCompanyAddressOnLine" IS
{create function GetCompanyAddressOnLine
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(in reqcompanyid 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 company.addr1,company.addr2,company.addr3,company.town,company.county,company.country,company.postcode into addr1,
addr2,addr3,town,county,country,postcode from company
where companyid=reqcompanyid;
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
}