From: Phillip Smith <phillip.smith@weatherbeeta.com.au>
To: pgsql-sql@postgresql.org
Subject: Differentiate Between Zero-Length String and NULL Column Values
Date: Tue, 30 Jan 2007 16:32:22 +1100
Message-ID: <016d01c74430$043b1b90$9b0014ac@wbaus090> (raw)
Hi All,
Small problem with 8.2.1, I have a temp table of basic stock details:
CREATE TEMP TABLE tmpstk
(
code varchar(6),
description varchar(38),
grp varchar(4),
brand text,
style text,
supplier varchar(6),
supplier_code text,
wholesale numeric(10,2),
retail numeric(10,2),
ean varchar(13)
)
WITHOUT OIDS;
This table is populated using a COPY query – works OK. If I try the
following query:
SELECT * FROM tmpstk
I get what I expect, almost 8000 rows including rows similar to the
following:
"401514","EQUINADE_SHOWSILK_SHAMPOO_5L","3209","EQUINADE","SHAMPOO","EQUEST"
,"401514","0.00","0.00","0.00","0.00","10.00","9329028056594"
"401600","A/DRESS_SHAMPOO_TEA_TREE_OIL_500ML","3208","AUSTRALIAN_DRESSAGE","
SHAMPOO","EQUEST","401600","0.00","0.00","0.00","0.00","10.00",""
The second row (401600) is what I’m interested in for this particular
problem. The problem is when I try and add a WHERE clause:
SELECT * FROM tmpstk WHERE ean = '';
SELECT * FROM tmpstk WHERE TRIM(ean) = '';
SELECT * FROM tmpstk WHERE ean = NULL;
None of the above queries return any rows.
What am I doing wrong? It should return the 401600 row above, along with
several hundred other rows. I have attached the bash script that actually
does this processing.
Help is much appreciated.
Cheers,
-p
Phillip Smith
IT Coordinator
Weatherbeeta P/L
AUSTRALIA
E. phillip.smith@NO-SPAM.weatherbeeta.com.au
*******************Confidentiality and Privilege Notice*******************
The material contained in this message is privileged and confidential to
the addressee. If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.
Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments
Attachments:
import-wb-stock.sh (application/x-sh, 2.3K) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: phillip.smith@weatherbeeta.com.au
Subject: Re: Differentiate Between Zero-Length String and NULL Column Values
In-Reply-To: <016d01c74430$043b1b90$9b0014ac@wbaus090>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox