Well I'm not fond of using a temporary table either. But how would I be able to iterate over a set of consumers while using a join ? From my (limited) , using only a join I would only be able to generate the data for a particular consumer , rather than all of them. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Stored-function-debugging-help-tp5028300p5028732.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general