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
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