Re: counting columns

From: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: counting columns
Date: 2007-08-29 23:43:23
Message-ID: 46D6049B.2010503@cox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/28/07 10:46, pere roca wrote:
> hi!
>
> I want different users to insert data and perform different analysis which
> will be inserted in an interactively created new column. The name of this
> new column should follow a logic name such as: fxanalysis_1 for the first
> user that perform the analysis called fx, fxanalysis_2 for the second...
> To get it, I think I should construct a function that counts how many
> columns have their name starting with fxanalysis.
> If count >=1, then alter table adding a new column with name fxanalysis_2
> and so on...
> One of the questions: how to COUNT COLUMNS? I can rename, add, alter
> columns... but count?

You'll need to go into the catalog.

Your idea, though, is poor. You should make a second table, where
the key is the same as the master table, plus a "sequence number".

If you want to do it your way, though, PostgreSQL supports array types.

- --
Ron Johnson, Jr.
Jefferson LA USA

Give a man a fish, and he eats for a day.
Hit him with a fish, and he goes away for good!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFG1gSbS9HxQb37XmcRAqw+AKC8lDaQZ6IQ2ugVZzfxuT8TlGeHvQCgsLic
esN5w79t4bGAnURm+Nulq20=
=PBHq
-----END PGP SIGNATURE-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-08-30 00:25:51 Re: ERROR: table row type and query-specified row type do not match
Previous Message Tom Lane 2007-08-29 23:32:55 Re: show connection limit?