Re: select as - Mailing list pgsql-general

From Michael Fuhr
Subject Re: select as
Date
Msg-id 20041223182029.GA64609@winnie.fuhr.org
Whole thread Raw
In response to select as  (Bambero <bambero@tlen.pl>)
List pgsql-general
On Thu, Dec 23, 2004 at 06:37:14PM +0000, Bambero wrote:

> Is there any easy way to select all fields from table (*) but the result
> should looks like this:
>
>   1|    2|    3
> ----+-----+------
> asas| asd | dasd
> ada | ads | dasa
>
> Column name should be a number of column.

Why do you need to do this?  Anyway, if you're making queries with
an interface that can fetch rows as an array, then you could display
column numbers based on their position in the array.

> I don't know what fields are in the table so:
>
> select fieldname as 1, fieldname2 as 2
>
> is useless.

What problem are you trying to solve?  Why are you querying a table
when you don't know what fields it has?  Are you building a generic
interface for querying any table?  If so, then you can get column
positions and types by examining the system catalogs.  See the
"System Catalogs" and "The Information Schema" chapters in the
PostgreSQL documentation (Information Schema is available in 7.4
and later).

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-general by date:

Previous
From: Lonni J Friedman
Date:
Subject: Re: monitoring tools
Next
From: Mark
Date:
Subject: update table with row locking