Thread: Using a variable as tablename ins plpgsql?

Using a variable as tablename ins plpgsql?

From
Glyn Astill
Date:
Hi people,

Hopefully this is a quickie, I want to pass in a table name to a plpgsql function and then use that table name in my
queries.

Is EXECUTE the only way to do this?

Ta
Glyn







Send instant messages to your online friends http://uk.messenger.yahoo.com

Re: Using a variable as tablename ins plpgsql?

From
"Pavel Stehule"
Date:
Hello

2008/10/20 Glyn Astill <glynastill@yahoo.co.uk>:
> Hi people,
>
> Hopefully this is a quickie, I want to pass in a table name to a plpgsql function and then use that table name in my
queries.
>
> Is EXECUTE the only way to do this?
>
> Ta
> Glyn
>

yes,

regards
Pavel Stehule

>
>
>
>
>
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

Re: Using a variable as tablename ins plpgsql?

From
"Fernando Moreno"
Date:
2008/10/20 Glyn Astill <glynastill@yahoo.co.uk>
Hi people,

Hopefully this is a quickie, I want to pass in a table name to a plpgsql function and then use that table name in my queries.

Is EXECUTE the only way to do this?
 
As far as I know, yes. That's the only way to create queries using dynamic table and column names.