Re: Variable column name

From: "Bob Pawley" <rjpawley(at)shaw(dot)ca>
To: "Bill Moran" <wmoran(at)potentialtech(dot)com>
Cc: "Postgresql" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Variable column name
Date: 2011-09-02 17:33:22
Message-ID: 114E7E9EA71B4295B2A2C1D3BE772965@BobPC
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----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, you might want to start with
this:
http://www.postgresql.org/docs/9.0/static/plpgsql-structure.html

Thanks for the suggestion.

Following is my interpretation of what I have read.

I am getting an error -- "column "1" does not exist"

Could someone point to what I am doing wrong?

Bob

Select 2 into point_array ;
Select "1" into column ;

Loop

Execute 'Update library.compare Set'
|| quote_ident (column[point_array])
|| '=
(select st_distance (st_geometryn(public.similar.the_geom, 1),
(st_geometryn(public.similar.the_geom, point_array)))/
public.similar.prime
from public.similar
where public.similar.sight_description = ''H_Line'')'
-- || newvalue
|| 'from public.import_process_transfer'
|| 'where library.compare.process_id =
public.import_process_transfer.process_id';
-- || quote_literal();

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2011-09-02 17:38:08 Re: Variable column name
Previous Message Tom Lane 2011-09-02 17:20:26 Re: UPDATE using query; per-row function calling problem