Postgresql Function Store Query Result In Variable