Re: dynamic table naming in function

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

Thanks for pointing me in the right direction. I read
about EXECUTE in the docs now.

> 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.

I'm not sure what you mean...

Is there a more suitable LANGUAGE declaration you
would recommend? If possible, I would also like to
return results from SELECT statments from the function
but EXECUTE doesn't return any results. I'm not tied
to plpgsql, but would like to make a couple dynamic
functions with whatever way is simplest or best tool
for the job.

--- Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> 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
>



__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message mike dixon 2005-10-29 19:29:32 pgsql "info" files?
Previous Message Joshua D. Drake 2005-10-29 19:10:19 Re: function that resolves IP addresses