| From: | "Andrey N(dot) Oktyabrski" <ano(at)antora(dot)ru> |
|---|---|
| To: | pgsql-ru-general(at)postgresql(dot)org |
| Subject: | Re: [pgsql-ru-general] Re: [pgsql-ru-general] Re[2]: [pgsql-ru-general] настройк |
| Date: | 2005-12-06 09:45:30 |
| Message-ID: | 43955DBA.2060600@antora.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Genix | 2005-12-06 13:24:49 | insert в varchar |
| Previous Message | Teodor Sigaev | 2005-12-06 09:15:25 | Re: [pgsql-ru-general] Re[2]: [pgsql-ru-general] настройк |