Is there an isnull function avaliable in postgres, such as:

  select isnull(dt_field, 'now') ...

Thanks

Fri, 26 Jun 1998 10:42:03 -0700
Kachun Lee <kachun@pathlink.net>
isnull function
> 
> Is there an isnull function avaliable in postgres, such as:
> 
>   select isnull(dt_field, 'now') ...
> 
> Thanks
> 
> 

I don't tbink so, but it would be nice.  I think Ingres has it.  It also
would not be hard to write as a loadable function.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Fri, 26 Jun 1998 15:13:34 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [SQL] isnull function]
At 03:13 PM 6/26/98 -0400, you wrote:
>> 
>> Is there an isnull function avaliable in postgres, such as:
>> 
>>   select isnull(dt_field, 'now') ...
>> 
>> Thanks
>> 
>> 
>
>I don't tbink so, but it would be nice.  I think Ingres has it.  It also
>would not be hard to write as a loadable function.
>
>-- 
>Bruce Momjian                          |  830 Blythe Avenue
>maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
>  +  If your life is a hard drive,     |  (610) 353-9879(w)
>  +  Christ can be your backup.        |  (610) 853-3000(h)
>

I tried, but the following code does not seem to work:

#include <string.h>
#include <stdio.h>
#include "postgres.h"
#include "libpq-fe.h" 
#include "utils/dt.h"

DateTime * is_null(DateTime *, DateTime *);

DateTime * is_null (DateTime * dt, DateTime * def)
{
        return dt ? dt : def;
}

I searched the doc/maillist, and I could not find how to test an arg for
NULL value. Should I post this to HACKER?

Fri, 26 Jun 1998 13:33:17 -0700
Kachun Lee <kachun@pathlink.com>
Re: [SQL] isnull function]
I posted this question a while back and received a response of 'is null'
such as:

select * from try where field is null;

Will give you all entries where the field 'field' does not yet contain a
value.  Works great and I hope will answer your original question.
(Now if only I could find an easy answer for mine :)

--
Colin Dick
On Call Internet Services
cdick@mail.ocis.net


On Fri, 26 Jun 1998, Kachun Lee wrote:

> At 03:13 PM 6/26/98 -0400, you wrote:
> >> 
> >> Is there an isnull function avaliable in postgres, such as:
> >> 
> >>   select isnull(dt_field, 'now') ...
> >> 
> >> Thanks
> >> 
> >> 
> >
> >I don't tbink so, but it would be nice.  I think Ingres has it.  It also
> >would not be hard to write as a loadable function.
> >
> >-- 
> >Bruce Momjian                          |  830 Blythe Avenue
> >maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
> >  +  If your life is a hard drive,     |  (610) 353-9879(w)
> >  +  Christ can be your backup.        |  (610) 853-3000(h)
> >
> 
> I tried, but the following code does not seem to work:
> 
> #include <string.h>
> #include <stdio.h>
> #include "postgres.h"
> #include "libpq-fe.h" 
> #include "utils/dt.h"
> 
> DateTime * is_null(DateTime *, DateTime *);
> 
> DateTime * is_null (DateTime * dt, DateTime * def)
> {
>         return dt ? dt : def;
> }
> 
> I searched the doc/maillist, and I could not find how to test an arg for
> NULL value. Should I post this to HACKER?
> 


Fri, 26 Jun 1998 13:41:22 -0700 (PDT)
Colin Dick <cdick@mail.ocis.net>
Re: [SQL] isnull function]
> 
> I tried, but the following code does not seem to work:
> 
> #include <string.h>
> #include <stdio.h>
> #include "postgres.h"
> #include "libpq-fe.h" 
> #include "utils/dt.h"
> 
> DateTime * is_null(DateTime *, DateTime *);
> 
> DateTime * is_null (DateTime * dt, DateTime * def)
> {
>         return dt ? dt : def;
> }
> 
> I searched the doc/maillist, and I could not find how to test an arg for
> NULL value. Should I post this to HACKER?
> 
> 

Having DateTime* be a NULL does not represent a NULL value in SQL
internally.

Not sure how to do it, because I don't rememeber where the NULL checking
is done.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Fri, 26 Jun 1998 22:11:56 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [SQL] isnull function]

> > Is there an isnull function avaliable in postgres, such as:
> >
> >   select isnull(dt_field, 'now') ...
> >
> > Thanks
> >
> >
>
> I don't tbink so, but it would be nice.  I think Ingres has it.  It also
> would not be hard to write as a loadable function.
>

Is it possible to do something like:

   select * from blah where x = ''

and get what he is asking for?

...james


Sat, 27 Jun 1998 06:29:30 -0400
James Olin Oden <joden@Lee.k12.nc.us>
Re: [SQL] isnull function]