pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Don Drake <dondrake@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: NULLS and string concatenation
Date: Fri, 19 Nov 2004 17:48:34 +0000
Message-ID: <419E31F2.4060104@archonet.com> (raw)
In-Reply-To: <6c21003b0411190912630d4afe@mail.gmail.com>
References: <6c21003b0411190912630d4afe@mail.gmail.com>

Don Drake wrote:
> select 'some text, should be null:'|| NULL
> 
> This returns NULL and no other text.  Why is that?  I wasn't expecting
> the "some text.." to disappear altogether.
> 
> Is this a bug?

No. Null is "unknown" if you append unknown (null) to a piece of text, 
the result is unknown (null) too.

If you're using NULL to mean something other than unknown, you probably 
want to re-examine your reasons why.

> I was able to work around the problem by using COALESCE (and casting
> variables since it wants the same data types passed to it).

That's the correct procedure (although ask yourself if you should have 
nulls rather than just empty strings).

-- 
   Richard Huxton
   Archonet Ltd



view thread (12+ messages)  latest in thread

Message-ID: <419E31F2.4060104@archonet.com>
Permalink:  ../419E31F2.4060104@archonet.com/
Also on:    postgresql.org/message-id/419E31F2.4060104@archonet.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, dondrake@gmail.com
  Subject: Re: NULLS and string concatenation
  In-Reply-To: <419E31F2.4060104@archonet.com>

* 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