Reorder sql transaction for PUT operations
If an update fails, this reorder will cause less work for a rollback.