Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
>>>I have an index on a date field that looks like thie: dtoc(< date >).
>>>I have a view which I use in a form that is used to add/update that table.
>>>
>>>When I call the tableupdate I get the following message.
>>>Error building key for index "< cdx file >" tag "< tag name >".
>>>
>>>Is there a setting or a work around for this problem?
>>
>>
>>I found it.
>>
>>"DTOC(dExpression | tExpression [, 1])
>>
>>1
>>Returns the date in a format suitable for indexing. This is particularly useful for maintaining the table records in chronological sequence.
>>
>>For example, to order table records in entry sequence, you could issue this command:
>>
>>INDEX ON DTOC(gdInvDate, 1) + gnInvTime TAG Timeindx"
>>
>>This resolved the issue.
>
>Or, a little simpler, dtos(gdInvDate) + gnInvTime.
>
>The problem is that dtoc() (without the second parameter) might give you different values on different runs, so it is not at all suitable for indexing. About as bad as having a variable-length index expression.
For me, the real reason not to use DTOC() is that it isn't accurate for sorting when multiple years are involved.
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.
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.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement