I wrote the generateUpdateQuery() function. It seems to work.