X-Original-To: pgsql-ru-general-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7509E9DCAEE for ; Tue, 6 Dec 2005 05:46:12 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74914-01 for ; Tue, 6 Dec 2005 05:46:13 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by postgresql.org (Postfix) with ESMTP id 8EB889DCD36 for ; Tue, 6 Dec 2005 05:46:08 -0400 (AST) Received: from office.antora.ru (office.antora.ru [81.26.141.122]) by svr2.postgresql.org (Postfix) with ESMTP id 3E55BF0B41 for ; Tue, 6 Dec 2005 09:46:09 +0000 (GMT) Received: from [192.168.1.111] (helo=[192.168.1.111]) by office.antora.ru with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.51) id 1EjZTP-00063v-Ah; Tue, 06 Dec 2005 12:50:59 +0300 Message-ID: <43955DBA.2060600@antora.ru> Date: Tue, 06 Dec 2005 12:45:30 +0300 From: "Andrey N. Oktyabrski" User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051118) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-ru-general@postgresql.org Subject: =?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?= References: <514320993.20051205165607@pochtamt.ru> <4394B817.6040000@sbin.org> <1753831930.20051206132811@pochtamt.ru> <439556AD.5080605@sigaev.ru> In-Reply-To: <439556AD.5080605@sigaev.ru> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=2.875 required=5 tests=[RCVD_IN_BL_SPAMCOP_NET=1.332, SUBJECT_ENCODED_TWICE=1.543] X-Spam-Score: 2.875 X-Spam-Level: ** X-Archive-Number: 200512/7 X-Sequence-Number: 464 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.