How to declare cursor if tablename is a variable?

From: "hu js" <hu(dot)bill2005(at)hotmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: How to declare cursor if tablename is a variable?
Date: 2007-03-14 08:14:07
Message-ID: BAY102-F38329B7028B182CFF13493F0730@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

See this:
“CREATE or replace function geo_polygon(tablename varchar) RETURNS integer
AS $$
DECLARE
objectid varchar;
tab varchar;
x1 float;
y1 float;

obj_num integer;
point_num integer;

polygonstr varchar;

cur_obj CURSOR FOR SELECT mrc_xy_position FROM tablename;
cur_point CURSOR FOR SELECT x,y FROM tablename where mrc_xy_position =
objectid;

BEGIN
…….“

Error if call the function. Neither to use “execute” . Who can solve it?
Thanks!

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Sabin Coanda 2007-03-14 12:44:53 reindex database
Previous Message Rodrigo De León 2007-03-14 01:48:50 Re: import CSV file