Creating cursors in sql and updating each line in cursor