[Please copy the mailing list on replies so others can participate
in and learn from the discussion.]
On Tue, Mar 20, 2007 at 02:28:15AM +0000, hu js wrote:
> It doesn't work. Because can't use variable for table name in query.
>
> Please tell me another way. Thanks
What exactly have you tried that doesn't work? Will neither of the
following do what you want? What version of PostgreSQL are you using?
DECLARE rec_obj record; query_obj text := 'SELECT mrc_xy_position FROM ' || quote_ident(tablename);
BEGIN FOR rec_obj IN EXECUTE query_obj LOOP [...] END LOOP;
or
DECLARE cur_obj refcursor; query_obj text := 'SELECT mrc_xy_position FROM ' || quote_ident(tablename);
BEGIN OPEN cur_obj FOR EXECUTE query_obj; [...]
--
Michael Fuhr