Re: dynamic table naming in function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthew Peter <survivedsushi(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: dynamic table naming in function
Date: 2005-10-29 18:16:26
Message-ID: 12012.1130609786@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matthew Peter <survivedsushi(at)yahoo(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2005-10-29 19:10:19 Re: function that resolves IP addresses
Previous Message Bruno Wolff III 2005-10-29 18:14:08 Re: dynamic table naming in function