agora inbox for pgsql-ru-general@postgresql.org  
help / color / mirror / Atom feed
From: Andrey N. Oktyabrski <ano@antora.ru>
To: pgsql-ru-general@postgresql.org
Subject: Re: [pgsql-ru-general] Re: [pgsql-ru-general] Re[2]: [pgsql-ru-general] настройк
Date: Tue, 06 Dec 2005 12:45:30 +0300
Message-ID: <43955DBA.2060600@antora.ru> (raw)
In-Reply-To: <439556AD.5080605@sigaev.ru>
References: <514320993.20051205165607@pochtamt.ru>
	<4394B817.6040000@sbin.org>
	<1753831930.20051206132811@pochtamt.ru>
	<439556AD.5080605@sigaev.ru>

Teodor Sigaev wrote:
> select 'test' || coalesce(NULL, '') || '' as ret;

>>>> Можно настроить PostgreSQL, чтобы запрос
>>>> select 'test' || NULL || '' as ret;
>>>> возвращал не пустую строку, а то, что есть ?
>>
>> Задача совершенно простая, в таблице есть поля "фамилия", "имя",
>> "отчество".
>> Я хочу чтобы запрос возвратил мне одно поле "Фамилия И.О.", а
>> отчество может быть NULL, и соответственно возвращается пустая строка.
>>
>> Стандартной функции на проверку строки на NULL, и замену на "" не
>> нашел. Написать свою ?
file:///usr/local/share/doc/postgresql/html/functions-conditional.html#AEN12614
9.13.2. COALESCE

COALESCE(value [, ...])

The COALESCE function returns the first of its arguments that is not
null. Null is returned only if all arguments are null. This is often
useful to substitute a default value for null values when data is
retrieved for display, for example:

SELECT COALESCE(description, short_description, '(none)') ...

Like a CASE expression, COALESCE will not evaluate arguments that are
not needed to determine the result; that is, arguments to the right of
the first non-null argument are not evaluated.



view thread (25+ messages)  latest in thread

Message-ID: <43955DBA.2060600@antora.ru>
Permalink:  ../43955DBA.2060600@antora.ru/
Also on:    postgresql.org/message-id/43955DBA.2060600@antora.ru

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-ru-general@postgresql.org
  Cc: ano@antora.ru
  Subject: Re: =?KOI8-R?Q?Re=3A_=5Bpgsql-ru-general=5D_Re=3A_=5Bpgsql-ru-?= =?KOI8-R?Q?general=5D_Re=5B2=5D=3A_=5Bpgsql-ru-general=5D_=CE=C1=D3?= =?KOI8-R?Q?=D4=D2=CF=CA=CB?=
  In-Reply-To: <43955DBA.2060600@antora.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox