BUG #5549: Feature: plpgsql should allow DECLARE cursor FOR EXECUTE '...' - Mailing list pgsql-bugs

From David Schmitt
Subject BUG #5549: Feature: plpgsql should allow DECLARE cursor FOR EXECUTE '...'
Date
Msg-id 201007091211.o69CBumY096641@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #5549: Feature: plpgsql should allow DECLARE cursor FOR EXECUTE '...'
List pgsql-bugs
The following bug has been logged online:

Bug reference:      5549
Logged by:          David Schmitt
Email address:      david@dasz.at
PostgreSQL version: 8 and 9
Operating system:   n/a
Description:        Feature: plpgsql should allow DECLARE cursor FOR EXECUTE
'...'
Details:

This is not implemented:

---------------------------------------------------------------------
CREATE OR REPLACE FUNCTION foo(tbl text) RETURNS void AS
$BODY$
DECLARE
    working_cursor NO SCROLL CURSOR FOR EXECUTE $$SELECT something $$ || tbl
|| $$ ... $$;
BEGIN
    FOR rec IN working_cursor LOOP
        -- ...
    END LOOP;
END$BODY$
LANGUAGE 'plpgsql' VOLATILE;
---------------------------------------------------------------------

The obvious workaround is hand-coding the LOOP with OPEN ... FOR EXECUTE and
manual FETCHing, but it would be great to have this missing piece supported
in syntax and avoid duplicating the error-prone hand-coding.



Thanks for your time and work!

pgsql-bugs by date:

Previous
From:
Date:
Subject: Re: pg_upgrade issues
Next
From: Tom Lane
Date:
Subject: Re: BUG #5549: Feature: plpgsql should allow DECLARE cursor FOR EXECUTE '...'