General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
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
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only