Tweak sql update function.

Use only one function to do the database update and pass as argument the
minimum number of affected rows that must be met.