Ray Madigan wrote:
> I thought that the documentation said I couldn't use EXECUTE on a SELECT
> INTO?
"37.6.5. Executing Dynamic Commands
Oftentimes you will want to generate dynamic commands inside your
PL/pgSQL functions, that is, commands that will involve different tables
or different data types each time they are executed. PL/pgSQL's normal
attempts to cache plans for commands will not work in such scenarios. To
handle this sort of problem, the EXECUTE statement is provided:
EXECUTE command-string [ INTO [STRICT] target ];
where command-string is an expression yielding a string (of type text)
containing the command to be executed and target is a record variable,
row variable, or a comma-separated list of simple variables and
record/row fields.
"
There's also a FOR..IN EXECUTE loop too
-- Richard Huxton Archonet Ltd