Issue LOOP-42 by tj: corrected sql update function with a patch