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