Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 0A4E89FBC5D for ; Tue, 29 May 2007 13:36:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21427-03 for ; Tue, 29 May 2007 13:36:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id D5C669FBB1A for ; Tue, 29 May 2007 13:36:02 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id D7ED075BA9; Tue, 29 May 2007 17:36:01 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 6F4B92740DA; Tue, 29 May 2007 17:36:16 +0100 (BST) Message-ID: <465C5671.50907@archonet.com> Date: Tue, 29 May 2007 17:36:01 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: Joshua Cc: pgsql-sql@postgresql.org Subject: Re: problems with SELECT query results References: <465C4B0B.4070906@joshuaneil.com> In-Reply-To: <465C4B0B.4070906@joshuaneil.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/186 X-Sequence-Number: 28466 Joshua wrote: > Hello, > > I am new to this list and have been working with PostgreSQL since January. > > Here is my problem, I hope someone here has some experience or can point > me in the right direction. I am writing the following query for a C# > program I am writing: > > SELECT 'PV.LINEITEM:' || partnum || ',' || round(onhand) || ',' || > round(qm5) || ',' || round(lsm4) || ',' || ',' || ',' || round(onorder) > || ',' || ',' || ',' || binone || ',' || ',' || round(backorderqty) || > ',' || ',' || round(onhold) || ',' || ',' || ',' || ',' || ',' || ',' || > ',' || round(qtyperjob) || ',' || round(ordermax) AS gmrim FROM slparts > WHERE vendor LIKE 'CH%' > > The query does work and I am getting results from the database. There > are values for all 'partnum' in the database, however, the query results > include blank fields here and there in between the returned records. Why > am I receiving blank fields for 'gmrim'???? This absolutely defies logic > and I cannot find any rhyme or reason for this problem. I cannot have > any blank rows in the query, and again the database is completely > populated with values. I'm not sure it is - I think you've got a NULL somewhere. Since NULL means "unknown" ('text' || NULL) = NULL Wrap all your column-references in COALESCE: e.g. COALESCE(partnum,'') and see if that solves it. If so, go back and find rows WHERE partnum IS NULL and correct them. Then set the NOT NULL constraint on the relevant columns. -- Richard Huxton Archonet Ltd