case statement as inline function?

Поиск
Список
Период
Сортировка
Искать
От
Mike Nolan
Тема
case statement as inline function?
Дата
Msg-id
200403241633.i2OGXeLa032518@gw.tssi.com
Список
Дерево обсуждения
case statement as inline function? Mike Nolan <nolan@gw.tssi.com>
Re: case statement as inline function? Richard Huxton <dev@archonet.com>
Re: case statement as inline function? Mike Nolan <nolan@gw.tssi.com>
Re: case statement as inline function? CoL <col@mportal.hu>
Periodically I need to write a complex case statement that I'd like to
be able to refer to in more than one place in a SQL command without having
to make sure that each copy of the case statement remains the same as
the query (to produce a mailing) is tailored.

Is there any way to treat it like an inline function so that I could write
something like the following (highly simplified):

   select case when A=1 then 1 when B=1 then 2 else null end 
   as mailtype, memname from master 
   where mailtype is not null;

I could do it as a user function, though that would be less convenient during 
the specification phase, which may happen every few days.  However, the 
columns referred to in the case statement can change too.  Is there a way 
to pass the entire set of columns in a table to a function?
--
Mike Nolan
В списке pgsql-general по дате отправления
От: Joshua D. Drake
Дата:
Сообщение: Re: ole db
От: Richard Huxton
Дата:
Сообщение: Re: unicode error and problem
FAQ