Re: Alias "all fields"?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Alias "all fields"?
Дата
Msg-id 22556.1189089563@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Alias "all fields"?  (Stefan Schwarzer <stefan.schwarzer@grid.unep.ch>)
Список pgsql-general
Stefan Schwarzer <stefan.schwarzer@grid.unep.ch> writes:
> Instead of this:
>         SELECT * FROM gdp WHERE y1970 NOT NULL AND y1971 NOT NULL
> AND .... y2005 NOT NULL
> I would like to have this:
>        SELECT * FROM gdp WHERE all-fields NOT NULL

This idea seems rather pointless for any operation other than
null-testing, since nothing else would apply uniformly to all data
types.  For null-testing you can use row null tests:

regression=# select * from int8_tbl i;
        q1        |        q2
------------------+-------------------
              123 |               456
              123 |  4567890123456789
 4567890123456789 |               123
 4567890123456789 |  4567890123456789
 4567890123456789 | -4567890123456789
               22 |
                  |
(7 rows)

regression=# select * from int8_tbl i where row(i.*) is not null;
        q1        |        q2
------------------+-------------------
              123 |               456
              123 |  4567890123456789
 4567890123456789 |               123
 4567890123456789 |  4567890123456789
 4567890123456789 | -4567890123456789
(5 rows)

regression=#

Note: this only works the way you want in 8.2 and up; earlier versions
thought that "row is not null" meant that *any* field is not null,
rather than *all*.

            regards, tom lane

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

Предыдущее
От: Franz.Rasper@izb.de
Дата:
Сообщение: Re: Alias "all fields"?
Следующее
От: Tino Wildenhain
Дата:
Сообщение: Re: Alias "all fields"?