Key constraint between temporary tables requires a primary key (not unique constraint)

Item Value
SQLCODE -865
Constant SQLE_INVALID_FOREIGN_KEY_INDEX
SQLSTATE 42R03
Sybase error code 1709
ODBC 2 State 42000
ODBC 3 State 42000

Probable cause 

Key constraint between temporary tables requires a primary key (not unique constraint) if the database uses combined indexes. Change the definition of the primary table using ALTER TABLE or rebuild the database.