Re: NULLS and string concatenation

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: NULLS and string concatenation
Дата
Msg-id 419E31F2.4060104@archonet.com
обсуждение исходный текст
Ответ на NULLS and string concatenation  (Don Drake <dondrake@gmail.com>)
Ответы Re: NULLS and string concatenation
Список pgsql-sql
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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: NULLS and string concatenation
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: NULLS and string concatenation