Re: [pgsql-ru-general] Re: [pgsql-ru-general] Re[2]: [pgsql-ru-general] настройк

Поиск
Список
Период
Сортировка
От Andrey N. Oktyabrski
Тема Re: [pgsql-ru-general] Re: [pgsql-ru-general] Re[2]: [pgsql-ru-general] настройк
Дата
Msg-id 43955DBA.2060600@antora.ru
обсуждение исходный текст
Ответ на Re: [pgsql-ru-general] Re[2]: [pgsql-ru-general] настройк  (Teodor Sigaev <teodor@sigaev.ru>)
Список pgsql-ru-general
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.

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

Предыдущее
От: Teodor Sigaev
Дата:
Сообщение: Re: [pgsql-ru-general] Re[2]: [pgsql-ru-general] настройк
Следующее
От: Genix
Дата:
Сообщение: insert в varchar