Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Jimmy,
>I am trying to set a primary key for a character field and a date field through an expression. I have thhe following:
>
>ssnumber+orderdate
>
>ssnumber is a character field and the orderdate is a date field. When I try and save it I get the following:
>
>Operator/operand type mismatch
>
>Newbie and need help.
There are several ways to convert a date to a character representation of the date. In this case, I would use the expression ssnumber + DTOS(orderdate). Given an ssNumber '999999999' and today's date the expression would generate the string '99999999920050723'.
That said, using the ss number + the order date as a primary key will limit the orders to one order per person per day. If the limitation enforces a business rule, that's fine. If, however, there is no business rule that states the a person is limited to one order per day, then you have a design issue that may come back to bite you. In that case you might want to consider a surrogate primary key such as an autogenerated integer key.
Hope this helps.
Jim Fisher
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