Re: dynamic table naming in function - Mailing list pgsql-general

From Tom Lane
Subject Re: dynamic table naming in function
Date
Msg-id 12012.1130609786@sss.pgh.pa.us
Whole thread Raw
In response to dynamic table naming in function  (Matthew Peter <survivedsushi@yahoo.com>)
Responses Re: dynamic table naming in function  (Matthew Peter <survivedsushi@yahoo.com>)
List pgsql-general
Matthew Peter <survivedsushi@yahoo.com> writes:
> Out of curiosity, I was wondering if it is possible to
> use dynamic table names in a function?

In plpgsql, you can do this by building dynamic query strings and
EXECUTE'ing them.  Most of the other PLs don't cache query plans
at all, and so all queries are effectively EXECUTE'd and there's
no issue.

You'll want to read up on quote_literal and quote_ident to help
you in building correct query strings.

            regards, tom lane

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: dynamic table naming in function
Next
From: "Joshua D. Drake"
Date:
Subject: Re: function that resolves IP addresses