From: Michael Fuhr <mike@fuhr.org>
To: hu js <hu.bill2005@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to declare cursor if tablename is a variable?
Date: Wed, 14 Mar 2007 08:09:34 -0600
Message-ID: <20070314140934.GA7086@winnie.fuhr.org> (raw)
In-Reply-To: <BAY102-F38329B7028B182CFF13493F0730@phx.gbl>
References: <BAY102-F38329B7028B182CFF13493F0730@phx.gbl>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@fuhr.org, hu.bill2005@hotmail.com
Subject: Re: How to declare cursor if tablename is a variable?
In-Reply-To: <20070314140934.GA7086@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox