postgresql select query result into variable