Did you create a cartesean product? How many loops are happening with the update statement? Is it possible to do the update in a single update statement rather than two nested loops?