getting jiggy with AS clauses

Поиск
Список
Период
Сортировка
От bille@npphotonics (Bill Eaton)
Тема getting jiggy with AS clauses
Дата
Msg-id 001401c27ae5$bf7fd300$1a64a8c0@bille
обсуждение исходный текст
Список pgsql-novice
It would be really nice to be able to get column labels from
within the database. Or in other words, trick the AS clause
into returning info from a SELECT query, i.e.
    SELECT header AS (SELECT header from labheaders where
dataset=1) FROM ...

Let's say you've got several columns of data from the
laboratory. It would be nice if I could store the column
headers in one place (LabHeaders) and store the data in
another place (LabData)

LabHeaders        LabData
----------        --------
dataset int8 <--> dataset int8
headers text[]    row int8
                  labrawdata float8[]

The tricky part is constructing a query that returns
something like

row     MyColumnDataFromLabHeadersTable
----   ---------------------------------
1        3.1415927
2        2.7128
3        5.3

Why not just used static column names, you ask? Well, we can
pretty much rest assured that the things that are measured
will occasionally change. And it's pretty silly to add a new
table every time a change is made.

I've played a bit with writing functions that return SETOF,
but with little success.

Ideas?

Bill Eaton
mailto://bill@npphotonics.com

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

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: San Francisco Bay Area PostgreSQL User's Group
Следующее
От: Andrew McMillan
Дата:
Сообщение: Re: [BUGS] Optimization disaster