# Checks if some changes can be done or not, without actually bool could_do_changes() { Database d = connect(); defer { d.disconnect(); } inserted_row = d.insert("some", "row"); defer { d.delete(inserted_row); } if (somecheck) return false; rows_to_update = d.query("oldvalue"); d.update(rows_to_update, "newvalue"); defer { d.update(rows_to_update, "oldvalue"); } if (somecheck) return false; to_delete = d.query("to_delete") d.delete(to_delete) defer { d.insert(to_delete); } return true; }