pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joseph Shraibman <jks@p1.selectacast.net>
To: jhunt@chac.qld.edu.au
Cc: Joseph Shraibman <jks@p1.selectacast.net>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: isnull
Date: Thu, 30 Mar 2000 18:07:16 -0500
Message-ID: <38E3DE24.72ACFA25@selectacast.net> (raw)
References: <004701bf9901$c2b322c0$9714a8c0@julies>
	<38E3D461.E80EB898@selectacast.net>
	<38E3DC17.3F1A865@chac.qld.edu.au>

Julie Hunt wrote:

> Yes, you're right.  I remember attempting to do an outer left join using the
> nullif but without success so I used the case function instead with success.
> Maybe someone else knows more about nullif and why it doesn't seem to work.
>
> Regards,
> Julie
>

I've actually taken a closer look at the web page and not only did the name change,
but I now notice that they change what it is supposed to do as well.  It does work
as currently defined, but I needed something that does what the original
documentation said:

IFNULL(input,non-NULL substitute)
 return second argument if first is NULL
 Example:        IFNULL(c1, 'N/A')


>
> Joseph Shraibman wrote:
>
> > Julie Hunt wrote:
> >
> > > Sorry, I haven't come across ifnull
> >
> > Ah, I think the documentation that came with 6.5.3 was wrong, because
> > http://www.postgresql.org/docs/postgres/functions.htm#AEN2257 has the function
> > nullif  where ifnull was in my documentation.  I don't get errors now, but it
> > just doesn't seem to do it's job.
> >
> > playpen=> insert into tablea values (100, null);
> > INSERT 23168 1
> > playpen=> select * from tablea;
> > indexa|data
> > ------+----
> >      1|   1
> >      2|   2
> >      3|   2
> >      4|   4
> >      7|   7
> >      6|   8
> >      5|   8
> >    100|
> > (8 rows)
> >
> > playpen=> select *, data from tablea;
> > indexa|data|data
> > ------+----+----
> >      1|   1|   1
> >      2|   2|   2
> >      3|   2|   2
> >      4|   4|   4
> >      7|   7|   7
> >      6|   8|   8
> >      5|   8|   8
> >    100|    |
> > (8 rows)
> >
> > playpen=> select *, nullif(data, 9) from tablea;
> > indexa|data|case
> > ------+----+----
> >      1|   1|   1
> >      2|   2|   2
> >      3|   2|   2
> >      4|   4|   4
> >      7|   7|   7
> >      6|   8|   8
> >      5|   8|   8
> >    100|    |
> > (8 rows)
> >
> > >
> > > Julie
> > >
> > > >Oops, my mistake.  I meant ifnull.  Whenever I try to use ifnull I get an
> > > >error so I have to use a case when a = null then default else a end.
> > > >
> > > >Julie Hunt wrote:
> > > >
> > > >> There is a space between is and null: is null
> > > >>
> > > >> Regards
> > > >>
> > > >> Joseph Shraibman wrote:
> > > >>
> > > >> > Could someone give me an example of isnull?  Whenever I try it I get an
> > > >> > error message.
> > > >




view thread (6+ messages)  latest in thread

Message-ID: <38E3DE24.72ACFA25@selectacast.net>
Permalink:  ../38E3DE24.72ACFA25@selectacast.net/
Also on:    postgresql.org/message-id/38E3DE24.72ACFA25@selectacast.net

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jks@p1.selectacast.net, jhunt@chac.qld.edu.au
  Subject: Re: isnull
  In-Reply-To: <38E3DE24.72ACFA25@selectacast.net>
  References: <004701bf9901$c2b322c0$9714a8c0@julies> <38E3D461.E80EB898@selectacast.net> <38E3DC17.3F1A865@chac.qld.edu.au> <38E3DE24.72ACFA25@selectacast.net>

* 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