Re: [GENERAL] Table name as parameter in function

2004-11-23 Thread Stephan Szabo
On Tue, 23 Nov 2004, Timothy Perrigo wrote: > Sorry for the brief response earlier; I was a bit rushed. After > looking into it, it's a bit messier than I thought (at least, as far as > I can tell...perhaps one of the gurus on this list can show us a better > way). > > Ordinarily, when you write

Re: [GENERAL] Table name as parameter in function

2004-11-23 Thread Timothy Perrigo
Sorry for the brief response earlier; I was a bit rushed. After looking into it, it's a bit messier than I thought (at least, as far as I can tell...perhaps one of the gurus on this list can show us a better way). Ordinarily, when you write select statements (for example) in a plpgsql functio

Re: [GENERAL] Table name as parameter in function

2004-11-23 Thread Alexander Pucher
Tim, I'm afraid, I didn't get the point. Could you give me an example code snippet of how to use the EXECUTE command in my case. Do I have to use the EXECUTE within my function? Thanks a lot, alex. Timothy Perrigo wrote: You'll need to use the EXECUTE command to build the SQL dynamically. See: h

Re: [GENERAL] Table name as parameter in function

2004-11-23 Thread Timothy Perrigo
You'll need to use the EXECUTE command to build the SQL dynamically. See: http://www.postgresql.org/docs/7.4/interactive/plpgsql- statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN On Nov 23, 2004, at 2:56 PM, Alexander Pucher wrote: Hi, struggling around with this for some time: How can I use a ta

[GENERAL] Table name as parameter in function

2004-11-23 Thread Alexander Pucher
Hi, struggling around with this for some time: How can I use a table name as a parameter in a PL/pgSQL function ?? I tried this but it didn't work... CREATE OR REPLACE FUNCTION my_row_count(text) RETURNS int4 AS ' DECLARE num_rows int4; BEGIN num_rows := (select count(*) from $1); RETURN n