Re: [GENERAL] creating a function with a variable table name

2007-03-01 Thread A. Kretschmer
am Thu, dem 01.03.2007, um 11:47:02 -0500 mailte George Nychis folgendes: > do I need to use PREPARE with it also? No. > > A. Kretschmer wrote: > >am Thu, dem 01.03.2007, um 11:17:46 -0500 mailte George Nychis folgendes: > >>Hey all, Please no top-posting with fullquote below your text. An

Re: [GENERAL] creating a function with a variable table name

2007-03-01 Thread George Nychis
do I need to use PREPARE with it also? A. Kretschmer wrote: am Thu, dem 01.03.2007, um 11:17:46 -0500 mailte George Nychis folgendes: Hey all, I'm trying to create a function in which the table a query is run on is variable, but I guess this is not as easy as I thought. BEGIN dp=> CREATE F

Re: [GENERAL] creating a function with a variable table name

2007-03-01 Thread A. Kretschmer
am Thu, dem 01.03.2007, um 11:17:46 -0500 mailte George Nychis folgendes: > Hey all, > > I'm trying to create a function in which the table a query is run on is > variable, but I guess this is not as easy as I thought. > > BEGIN > dp=> CREATE FUNCTION stats_addr_dst(date,text) > ... > dp'>

Re: [GENERAL] creating a function with a variable table name

2007-03-01 Thread Joshua D. Drake
> dp'> HAVING sum(dst_packets)>0 > dp'> ORDER BY sum(dst_packets) DESC;' > dp-> LANGUAGE SQL; > ERROR: syntax error at or near "$2" at character 179 > LINE 6: FROM $2 >^ > How can I pass the table name? Look at the EXECUTE option in plpgsql. Joshua D. Drake

[GENERAL] creating a function with a variable table name

2007-03-01 Thread George Nychis
Hey all, I'm trying to create a function in which the table a query is run on is variable, but I guess this is not as easy as I thought. BEGIN dp=> CREATE FUNCTION stats_addr_dst(date,text) dp-> RETURNS setof addr_count dp-> AS 'SELECT ip,sum(dst_packets) dp'> FROM( dp'> (SELECT dst_