Improve SQL grants update procedure.