> Why does my stored function returns only the first row of the query instead
> of the whole set of query?
Did you declare your function to return "setof <whatever>" ?
I did but I don't know if I have to iterate/loop and use "return next setof_foo"
or just use return next as it is.