Re: [GENERAL] function with tablename parameter

2003-10-27 Thread Adam Witney
To use dynamic queries you will probably have to use EXECUTE, take a look here http://www.postgresql.org/docs/7.3/interactive/plpgsql-statements.html#PLPGS QL-STATEMENTS-EXECUTING-DYN-QUERIES Although that page says that EXECUTE does not support SELECT INTO queries, but you may be able to build

Re: [GENERAL] function with tablename parameter

2003-10-27 Thread Stephan Szabo
On Mon, 27 Oct 2003, Miso Hlavac wrote: > hello, > > it is possible to write something similar??? > > create function get_count(varchar(32)) RETURNS int4 AS ' > DECLARE > tmp int4; > BEGIN > SELECT COUNT(*) INTO tmp FROM $1; > RETURN tmp; > END;' LANGUAGE 'plpgsql'; Youll need to do somethi

[GENERAL] function with tablename parameter

2003-10-27 Thread Miso Hlavac
hello, it is possible to write something similar??? create function get_count(varchar(32)) RETURNS int4 AS ' DECLARE tmp int4; BEGIN SELECT COUNT(*) INTO tmp FROM $1; RETURN tmp; END;' LANGUAGE 'plpgsql'; SELECT get_count('k_part'); SQL error: ERROR: parser: parse error at or near "$1" a