Re: dynamic table names

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: dynamic table names
Date: 2013-07-17 20:53:07
Message-ID: 51E70433.8060703@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/17/2013 02:39 PM, John Smith wrote:
> guys,
>
> have to use legacy 8.1.
>
> i have 100,000 tables in a schema that need to be queried (optimizing
> this by combining them into one will have to wait).
>
> so my query goes like so:
>
> > execute 'select * from ' || tabname::regclass || ' where firstname =
> "john"' into e;
>
> but i am getting an error:
>
> > ERROR: syntax error at or near "'select * from '" at character 9
>
> ? do someone have a stored procedure for this?
>
> http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
> http://www.postgresql.org/message-id/aa44f4a30510071254p46064ca0vff639cd492b22c0b@mail.gmail.com
> http://stackoverflow.com/questions/5772699/postgresql-dynamic-table-access
> http://www.sql-workbench.net/
>
> thanks, jzs
>

Sorry, disregard prev post

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2013-07-17 20:59:10 Re: dynamic table names
Previous Message Rob Sargent 2013-07-17 20:52:12 Re: dynamic table names