When you turn off autocommit as i suggested, then you would rather have this as a prepared statement instead.
That way when the changeset fails, the entire 'transaction' is rolled back and not have it partially done.