| From: | Richard Huxton <dev(at)archonet(dot)com> |
|---|---|
| To: | Joshua <joshua(at)joshuaneil(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: problems with SELECT query results |
| Date: | 2007-05-29 16:36:01 |
| Message-ID: | 465C5671.50907@archonet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ABHANG RANE | 2007-05-29 16:42:59 | opclass for real[] |
| Previous Message | PFC | 2007-05-29 16:25:50 | Re: problems with SELECT query results |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joshua | 2007-05-29 17:46:45 | Re: problems with SELECT query results |
| Previous Message | Joshua | 2007-05-29 15:47:23 | problems with SELECT query results |