Differentiate Between Zero-Length String and NULL Column Values

Поиск
Список
Период
Сортировка
От Phillip Smith
Тема Differentiate Between Zero-Length String and NULL Column Values
Дата
Msg-id 016d01c74430$043b1b90$9b0014ac@wbaus090
обсуждение исходный текст
Ответы Re: Differentiate Between Zero-Length String and NULL Column Values
Re: Differentiate Between Zero-Length String and NULL Column Values
Список pgsql-sql
Hi All,

Small problem with 8.2.1, I have a temp table of basic stock details:CREATE TEMP TABLE tmpstk(  code varchar(6),
descriptionvarchar(38),  grp varchar(4),  brand text,  style text,  supplier varchar(6),  supplier_code text,
wholesalenumeric(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
WHERETRIM(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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Function returning SETOF using plpythonu
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Differentiate Between Zero-Length String and NULL Column Values