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 something a little more complicated like: create function get_count(varchar) RETURNS int8 AS ' DECLARE tmp record; BEGIN FOR tmp IN EXECUTE ''SELECT COUNT(*) AS count FROM '' || $1 LOOP RETURN tmp.count; END LOOP; END;' LANGUAGE 'plpgsql'; ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match