>For me, the real reason not to use DTOC() is that it isn't accurate for sorting when multiple years are involved.
That, too. But whether this matter or not depends on what you use the index for: sorting, I frequently do with SELECT - SQL commands, just before running the report. The index might be used to ensure uniqueness, or to find data.
>As a practical matter, unless you are writing an international application, SET DATE won't change so you don't have to worry about getting different values on different runs. That also wouldn't lead to the problem when building the key. You'ld simply get a wrong result rather than an error.
Even if you program for a single country, you may want to give the user some control, e.g., SET SYSFORMATS.
>My guess is that the error happened because SET CENTURY changed between the time the index was built and the record was added. DTOC() now returns a different length value and the index can't accept it.
Quite possible. I am not sure, though.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)