postgresql function store select into variable