All Forums Tools
Caleks 2 posts Joined 12/05
02 Mar 2006
Autonumber as Composed key

Situation: At SQL Assistant, I need to create a table using an autonumber field as part of a composed primary keyComplication: When I set that autonumber field on UNIQUE PRIMARY INDEX statement, I get an error msg 5784 - “illegal use of identity field”.What am I doing wrong? Where can I find more details about this kind of error msg?Eg:CREATE TABLE LIB.TABLE ( Transaction_ID INTEGER TITLE 'Transaction ID' NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1INCREMENT BY 1 MINVALUE 1MAXVALUE 999999999NO CYCLE), Party_ID INTEGER TITLE 'Party ID' NOT NULL)UNIQUE PRIMARY INDEX ( Transaction_ID , Party_ID ); The intention is to have a table like if we have this on the table:Transaction_ID Party_ID1 11 22 1RgdsCassiano

tstover-109 2 posts Joined 07/04
07 Mar 2006

Identity columns cannot be used as part of a composite primary or secondary index. It doesn't make sense as part of a PI since the identity is inherently unique. Take a look at the create table (column definition clause) documentation, it's on page 1-318 in the V2R5.1 Data Definition Statements manual.

You must sign in to leave a comment.