Re: Inserting values into a variable table - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: Inserting values into a variable table
Date
Msg-id 20061125144343.H77387@megazone.bigpanda.com
Whole thread Raw
In response to Inserting values into a variable table  ("Greg Quinn" <greg@officium.co.za>)
Responses Re: Inserting values into a variable table  ("Andrej Ricnik-Bay" <andrej.groups@gmail.com>)
List pgsql-novice
On Sat, 25 Nov 2006, Greg Quinn wrote:

> I am creating a function for inserting values into a table.
>
> The problem is the tables have various names, depending on the userid.
>
> i.e
>
> email_inbox_a608ac4e-5215-4758-905e-78cfb809aebc
>
> is for one user, while�
>
> email_inbox_c86hce32-4758-905e-gfkk439d83jd
>
> is for another.
>
> I am trying in my sql, to pass the tablename as a parameter,
>
> i.e
>
> select * from $1 where messageid  = $2
>
> but the compiler is not accepting it. What is recommended?

You can't use arguments directly as a replacement for the table name in
sql or plpgsql functions. In plpgsql, you can build up a query string and
use execute.

You may consider seeing whether or not there's another way to lay out
the data as well that might be easier to work with.

pgsql-novice by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: Inserting values into a variable table
Next
From: "Andrej Ricnik-Bay"
Date:
Subject: Re: Inserting values into a variable table