title: Cannot add a Primary Key to AS400 table because of foreign key that doesn't exist
body: <p>I have a table on an IBMi/System-i/iSeries/AS400 that has no foreign keys, primary keys or constraints of any kind.  I am attempting to add a primary key using SQL:</p>
  
  <p><code>ALTER TABLE MYLIB.TBLGB ADD CONSTRAINT MYLIB.R_MYLIB_PK_GB PRIMARY KEY (GBAPP, GBTSK, GBSET, GBSTP)</code></p>
  
  <p>Which results in:</p>
  
  <p><code>Error: [SQL0538] The FOREIGN key in constraint R_MYLIB_PK_GB in MYLIB not same as the parent key. Cause . . . . . :   The FOREIGN key in constraint R_MYLIB_PK_GB in MYLIB is not the same as the parent key of table *N in *N. The FOREIGN key must have the same number of columns as the parent key and the data type and attributes of the FOREIGN key must be identical to the data type and attributes of the corresponding column of the parent key. Recovery  . . . :   Correct the statement so that the description of the FOREIGN key conforms to that of the parent key of the specified table.</code></p>
  
  <p>I'm totally baffled by this because there is definitely no foreign key linked to this table.  In fact, I have removed all constraints from all tables in this library.  What can I look at to determine what is blocking this?</p>
  
  <p>One additional interesting detail is that this has worked fine on other, essentially identical libraries...</p>