Hi John Thanks for response. > In other words, what does > select * from fun_compras_calculado(); > return and if it is not an error, why is it wrong? My problem is in CREATE the function, see: marcos@servidor$ psql teste -U teste < teste.sql ERRO: tipo "tipo_compras_calculado" não existe In english I think that it means ERROR: type "tipo_compras_calculado" not exists. This is my problem with this SP... Marcos.