Re: Computed table name in function - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Computed table name in function
Date
Msg-id 470D1F54.6090200@archonet.com
Whole thread Raw
In response to Re: Computed table name in function  ("Ray Madigan" <ray@madigans.org>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Daniel Drotos
Date:
Subject: Re: Computed table name in function
Next
From: Mike Adams
Date:
Subject: Refactored queries needing validation of syntactic equivalence