Re: [SQL] Helper aggregate function

2008-02-03 Thread Christian Kindler
hi in this case you have to use execute: >> select $1,count(*) from $2 group by $1 order by $1; execute into myResultSet 'select ' || $1 || ' from ' || $2 || ' group by ' || $1 || ' order by ' || $2; see plpgsql docs for detailed information christian On Sun, February 3, 2008 19:5

Re: [SQL] Helper aggregate function

2008-02-03 Thread Robins Tharakan
Please correct me if I am wrong, but as the last few lines of the first section in the given document says, you can use $n only for values and not for identifiers. http://www.postgresql.org/docs/8.3/static/xfunc-sql.html And one more thing, may be you would want to use a user-defined return type

[SQL] Helper aggregate function

2008-02-03 Thread sergey kapustin
Hello! Can anyone tell me how i do this properly? create or replace function agg(varchar,varchar) returns void as $func$ select $1,count(*) from $2 group by $1 order by $1; $func$ Language SQL; Right now this wives me "ERROR: syntax error at or near "$2" at character 97 select $1,count(*