postgresql select function result into variable