Re: [GENERAL] Variable column name

2011-09-02 Thread Scott Ribe
On Sep 2, 2011, at 2:31 PM, Bob Pawley wrote: > It seems to work when I hard code the column name and array point, so I was > hoping to make it work through a loop using variables for column and array > point. > > Does this make sense?? Building queries this way is tedious & error prone; that'

Re: [GENERAL] Variable column name

2011-09-02 Thread Bob Pawley
-Original Message- From: Bill Moran Sent: Friday, September 02, 2011 10:53 AM To: Bob Pawley Cc: Postgresql Subject: Re: [GENERAL] Variable column name In response to "Bob Pawley" : I am getting an error -- "column "1" does not exist" Select

Re: [GENERAL] Variable column name

2011-09-02 Thread Bill Moran
In response to "Bob Pawley" : > > I am getting an error -- "column "1" does not exist" > Select "1" into column ; Where are you selecting "1" from? This query has no FROM clause, so of course the column doesn't exist. The previous query, "SELECT 2 INTO point_array" is going to put the i

Re: [GENERAL] Variable column name

2011-09-02 Thread Bob Pawley
-Original Message- From: Raymond O'Donnell Sent: Friday, September 02, 2011 10:38 AM To: Bob Pawley Cc: Bill Moran ; Postgresql Subject: Re: [GENERAL] Variable column name On 02/09/2011 18:33, Bob Pawley wrote: -Original Message- From: Bill Moran Sent: Thu

Re: [GENERAL] Variable column name

2011-09-02 Thread Raymond O'Donnell
On 02/09/2011 18:33, Bob Pawley wrote: > > > -Original Message- >> From: Bill Moran > Sent: Thursday, September 01, 2011 8:19 AM > To: Bob Pawley > Cc: Postgresql > Subject: Re: [GENERAL] Variable column name > > http://www.postgresql.org/docs/9

Re: [GENERAL] Variable column name

2011-09-02 Thread Bob Pawley
-Original Message- From: Bill Moran Sent: Thursday, September 01, 2011 8:19 AM To: Bob Pawley Cc: Postgresql Subject: Re: [GENERAL] Variable column name http://www.postgresql.org/docs/9.0/static/plpgsql-statements.html Section 39.5.4 If you're not familiar with plpgsql at all

Re: [GENERAL] Variable column name

2011-09-01 Thread Bill Moran
In response to "Bob Pawley" : > > From: Bill Moran > > In response to "Bob Pawley" : > > > > 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

Re: [GENERAL] Variable column name

2011-09-01 Thread Adrian Klaver
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&quo

Re: [GENERAL] Variable column name

2011-09-01 Thread Scott Ribe
On Sep 1, 2011, at 9:04 AM, Bob Pawley wrote: > Would it be possible for you to point me to an example?? The EXECUTE command is what you want. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- Sent via pgsql-general mailing list (pgsql-general@

Re: [GENERAL] Variable column name

2011-09-01 Thread Bob Pawley
-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" : I want to add information to multiple columns (20 – 40) by employing a loop. Each pass o

Re: [GENERAL] Variable column name

2011-09-01 Thread Bill Moran
In response to "Bob Pawley" : > > 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 wor

[GENERAL] Variable column name

2011-09-01 Thread Bob Pawley
Hi 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 cre

Re: [GENERAL] Variable column name in plpgsql function

2004-12-01 Thread mark
Richard Huxton wrote: George Woodring wrote: Is possible to declare a variable to build the column name Tableid varchar(20) := TG_RELNAME || ''id''; And then use this variable to get the PK value? Tableidvalue int4 := NEW.tableid; No. You can build a dynamic query via EXECUTE, but that can't acces

Re: [GENERAL] Variable column name in plpgsql function

2004-12-01 Thread Richard Huxton
George Woodring wrote: Is possible to declare a variable to build the column name Tableid varchar(20) := TG_RELNAME || ''id''; And then use this variable to get the PK value? Tableidvalue int4 := NEW.tableid; No. You can build a dynamic query via EXECUTE, but that can't access NEW/OLD. -- Richa

[GENERAL] Variable column name in plpgsql function

2004-12-01 Thread George Woodring
I am trying to create a trigger that needs to capture the primary key value out of NEW variable. However the trigger can be called from 2 different tables whose PKs are Table1id Table2id Is possible to declare a variable to build the column name Tableid varchar(20) := TG_RELNAME || ''id''; And