From: Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
To: Ed Loehr <eloehr@austin.rr.com>
Cc: Joseph Shraibman <jks@p1.selectacast.net>
Cc: pgsql-interfaces@postgreSQL.org <pgsql-interfaces@postgreSQL.org>
Subject: Re: [INTERFACES] selectecting not null varchars.
Date: Thu, 24 Feb 2000 14:40:06 -0600
Message-ID: <20000224144006.B11186@rice.edu> (raw)
In-Reply-To: <38B58ED8.FDE3E3C7@austin.rr.com>
References: <38B58AAE.B28DD6CB@selectacast.net>
<38B58ED8.FDE3E3C7@austin.rr.com>
On Thu, Feb 24, 2000 at 02:04:40PM -0600, Ed Loehr wrote:
> Joseph Shraibman wrote:
> >
> > select * from directory where h != null ;
> > ... gets you this:
> > ERROR: parser: parse error at or near ";"
>
> Postgresql's SQL "not equal" operator is "<>"...Try this:
>
> select * from directory where h <> null;
Which is still throw an error. and the SQL standard way to test for
NOT NULL is:
SELECT * FROM directory WHERE h IS NOT NULL;
Here's an example:
test=> \d test
Table = test
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| date | int4 default now ( ) | 4 |
| t | text | var |
+----------------------------------+----------------------------------+-------+
test=> insert into test (t) values ('');
INSERT 869922 1
test=> select * from test;
date|t
---------+-----
949357548|two
949357551|later
951424534|
-1|one
951424715|
(5 rows)
test=> select * from test where t is not null;
date|t
---------+-----
949357548|two
949357551|later
-1|one
951424715|
(4 rows)
test=>
test=> select * from test where length(t) >0;
ERROR: Null input to textlen
test=> select * from test where t is not null and length(t) >0;
date|t
---------+-----
949357548|two
949357551|later
-1|one
(3 rows)
test=>
Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
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-interfaces@postgresql.org
Cc: reedstrm@wallace.ece.rice.edu, eloehr@austin.rr.com, jks@p1.selectacast.net
Subject: Re: [INTERFACES] selectecting not null varchars.
In-Reply-To: <20000224144006.B11186@rice.edu>
* 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