| From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Cc: | "Bob Pawley" <rjpawley(at)shaw(dot)ca>, "Bill Moran" <wmoran(at)potentialtech(dot)com> |
| Subject: | Re: Variable column name |
| Date: | 2011-09-01 15:16:23 |
| Message-ID: | 201109010816.24049.adrian.klaver@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thursday, September 01, 2011 8:04:49 am Bob Pawley wrote:
> -----Original Message-----
> From: Bill Moran
> Sent: Thursday, September 01, 2011 7:59 AM
> To: Bob Pawley
> Cc: Postgresql
> Subject: Re: [GENERAL] Variable column name
>
> In response to "Bob Pawley" <rjpawley(at)shaw(dot)ca>:
> > I want to add information to multiple columns (20 – 40) by employing a
> > loop. Each pass of the loop will populate one column with an array.
> >
> > I have tried and I have read that variables can not be used to control
> > column names.
> >
> > Is there a means of working around this restriction other than creating
> > 20 to 40 hard coded statements??
>
> You can generate dynamic SQL statements with plpgsql.
>
> Would it be possible for you to point me to an example??
http://www.postgresql.org/docs/9.0/interactive/plpgsql-statements.html#PLPGSQL-
STATEMENTS-EXECUTING-DYN
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bill Moran | 2011-09-01 15:19:09 | Re: Variable column name |
| Previous Message | Scott Ribe | 2011-09-01 15:13:37 | Re: Variable column name |