Thank you Craig, this has worked in my custom function too: BEGIN PERFORM check_positions(in_uid, in_gid, in_tiles);
CREATE TEMP TABLE _words ON COMMIT DROP AS SELECT out_word AS word, max(out_score) AS score FROM check_words(in_uid, in_gid, in_tiles) GROUP BY word, gid; PL/pgSQL is weird, but fun :-) I like that I can RAISE EXCEPTION in my custom function and PostgreSQL rolls everything back. Regards Alex