Re: [GENERAL] dynamic table/col names in plpgsql

2007-06-26 Thread Martijn van Oosterhout
On Sat, Jun 23, 2007 at 09:43:01PM -0600, gary jefferson wrote: Is there a way to use a variable as the name of a table or column in plpgsql? No, plpgsql is statically typed, it can't handle the possiblity of the types of variables changing. Use a more dynamic language(perl/tcl/python/etc...)

Re: [GENERAL] dynamic table/col names in plpgsql

2007-06-25 Thread gary jefferson
ugh, I'm going down a rathole with this... the dynamic part of the query is the table name, and therefore, if I want to select into a row variable, that variable's declaration needs to be dynamic, too. That seems kind of crazy, and I see no way to do that anyway. Maybe I'm going about this all

[GENERAL] dynamic table/col names in plpgsql

2007-06-25 Thread gary jefferson
Is there a way to use a variable as the name of a table or column in plpgsql? This might be a simple question, but I can't find the answer in the docs. http://www.postgresql.org/docs/8.2/interactive/plpgsql-declarations.html hints that there are data types that correspond to table/column, but I

Re: [GENERAL] dynamic table/col names in plpgsql

2007-06-25 Thread gary jefferson
Thanks Michael and Steve. Related question: If I previously had a IF EXISTS (select ...) statement, and the 'select ...' part now needs to be run with EXECUTE, how do I check for existence? It looks like I need to do an 'INTO' with a row variable? I can't seem to find an example snippet of

[GENERAL] dynamic table/col names in plpgsql

2007-06-23 Thread gary jefferson
Is there a way to use a variable as the name of a table or column in plpgsql? This might be a simple question, but I can't find the answer in the docs. http://www.postgresql.org/docs/8.2/interactive/plpgsql-declarations.html hints that there are data types that correspond to table/column, but I

Re: [GENERAL] dynamic table/col names in plpgsql

2007-06-23 Thread Michael Glaesemann
On Jun 23, 2007, at 22:47 , gary jefferson wrote: Is there a way to use a variable as the name of a table or column in plpgsql? AIUI, you need to use EXECUTE and build the query string yourself. http://www.postgresql.org/docs/8.2/interactive/plpgsql-

Re: [GENERAL] dynamic table/col names in plpgsql

2007-06-23 Thread Steve Atkins
On Jun 23, 2007, at 8:47 PM, gary jefferson wrote: Is there a way to use a variable as the name of a table or column in plpgsql? This might be a simple question, but I can't find the answer in the docs. http://www.postgresql.org/docs/8.2/interactive/plpgsql- declarations.html hints that