X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9010F474E5C for ; Thu, 20 Feb 2003 06:08:37 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 46547-07 for ; Thu, 20 Feb 2003 06:08:26 -0500 (EST) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by postgresql.org (Postfix) with ESMTP id C1104474E4F for ; Thu, 20 Feb 2003 06:08:26 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.36 #2) id 18loZ1-0000iq-0Z; Thu, 20 Feb 2003 11:08:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 29F2016BEB; Thu, 20 Feb 2003 11:08:26 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 8CD1E16A5C; Thu, 20 Feb 2003 11:08:25 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Stephen.Thompson@bmwfin.com, pgsql-sql@postgresql.org Subject: Re: VIEW or Stored Proc - Is this even possible? Date: Thu, 20 Feb 2003 11:08:23 +0000 User-Agent: KMail/1.4.3 References: <3D6DE68CE505D311B2540020482D02530BE2C5C3@EXCHANGESRV> In-Reply-To: <3D6DE68CE505D311B2540020482D02530BE2C5C3@EXCHANGESRV> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200302201108.23768.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/454 X-Sequence-Number: 11852 On Thursday 20 Feb 2003 10:09 am, Stephen.Thompson@bmwfin.com wrote: > Hello, > > Thanks for your suggestion I will look into this further. > > The reason this issue exists is to do with address details. What we have = is > an address table based upon the PAF address structure. IE house number, > house name, street, locality etc. The software that we are using to perfo= rm > a mail merge will not remove blank lines from the address so we can end up > with an address label looking as: > > My House > > Main Street > > Any Town > County Ah - what an irritating bit of software. I'd be tempted to write a merged_address() function to return the whole thi= ng=20 as a multi-line field if your mailmerge can handle that. It would do=20 something like: SELECT COALESCE(street || '\n','') || COALESCE(town || '\n','') ||=20 COALESCE(county || '\n','') FROM my_addr; and then trim the trailing '\n'. Failing that, seeing as you're only ever going to have a few fields to deal= =20 with you could define a mailing_list view which hard-coded address lines, b= ut=20 you're going to end up with nested CASE elements. --=20 Richard Huxton