Re: How to declare cursor if tablename is a variable? - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: How to declare cursor if tablename is a variable?
Date
Msg-id 20070314140934.GA7086@winnie.fuhr.org
Whole thread Raw
In response to How to declare cursor if tablename is a variable?  ("hu js" <hu.bill2005@hotmail.com>)
List pgsql-sql
On Wed, Mar 14, 2007 at 08:14:07AM +0000, hu js wrote:
> CREATE or replace function geo_polygon(tablename varchar) RETURNS 
> [...]
>    cur_obj CURSOR FOR SELECT mrc_xy_position FROM tablename;    
>    cur_point CURSOR FOR SELECT x,y FROM tablename where mrc_xy_position = 
> objectid;
> 
> Error if call the function. Neither to use “execute” . Who can solve 
> it? Thanks!

Are you sure you need to use cursors?  Can you not build the query
strings and use EXECUTE or "FOR variable IN EXECUTE query LOOP"?

-- 
Michael Fuhr


pgsql-sql by date:

Previous
From: Achilleas Mantzios
Date:
Subject: Re: reindex database
Next
From: T E Schmitz
Date:
Subject: Re: import CSV file