Re: [INTERFACES] selectecting not null varchars. - Mailing list pgsql-interfaces

From Ross J. Reedstrom
Subject Re: [INTERFACES] selectecting not null varchars.
Date
Msg-id 20000224144006.B11186@rice.edu
Whole thread Raw
In response to Re: [INTERFACES] selectecting not null varchars.  (Ed Loehr <eloehr@austin.rr.com>)
List pgsql-interfaces
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


pgsql-interfaces by date:

Previous
From: Ed Loehr
Date:
Subject: Re: [INTERFACES] selectecting not null varchars.
Next
From: Mike Mascari
Date:
Subject: Re: [INTERFACES] selectecting not null varchars.