#plpgSQL function can't just run a query; you have to put the results somewhere.
http://stackoverflow.com/a/16688055/1964078
but you can’t also RETURN QUERY on an anonymous function. so answer is to create a temp table:
http://www.ienablemuch.com/2010/12/return-results-from-anonymous-code.html
















