added codes to stop insertion into message tables if any errors occur during insert to MTs