ok so my probelm is I have a simple function like this CREATE OR REPLACE FUNCTION bookid(_tabela varchar) RETURNS integer AS $ $ DECLARE _id integer := 0; BEGIN SELECT INTO _id id FROM _tabela order by id desc limit 1; RETURN _id+1; END; $$ LANGUAGE plpgsql; and the problem is i can run this function cos im passing string to SQL statement and not the table object. hym what can I do about it to have function that will give me next id number back; ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match