Question

How do I create a primary key index from two or more columns in Visual FoxPro 9? The columns may be of different types.

Was it helpful?

Solution

Compound indexes should be strings, so use the appropriate function (STR(), DTOS(), etc.) to convert the field before concatenating it. See the MSDN documentation for more details.

OTHER TIPS

Another word of caution is to make sure you never trim the character representation of any of the columns included in the keys.

Something else you should be aware of is that referential integrity code generated by VFP is sometimes not clean or designed to work well with concatenated keys. Code is a lot simpler for surrogate keys (single meaningless column, normally integer or GUID). It might be too late in the design for you to consider this, but I will put it out here just in case it is still in the design stage or still a practical change to make.

Rick Schummer VFP MVP

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top