1 Reply Latest reply on Dec 6, 2012 8:31 PM by Justin B-Oracle

    How to use transformation script to add FK to relational model

    Justin B-Oracle

      I've looked through a few of the examples dealing with Foreign Key's, but I can't seem to get the code correct to add a new FK to a table and use the existing columns in the table.

      This code will add a Foreign Key from ENVIRONMENT_REQUEST to the ENVIRONMENT table pointing to the columns in the ENVIRONMENT_PK index. The problem is that it also adds a new column in the ENVIRONMENT_REQUEST table to be used for the Foreign Key.

      table = model.getTableSet().getByName("ENVIRONMENT_REQUEST");
      remoteKey = model.getGlobalIndexSet().getByName("ENVIRONMENT_PK");
      fk = table.addFK(model.getGlobalIndexSet().getByName("ENVIRONMENT_PK"));

      I have tried creating a localFKIndex but the generated column still exists. Is there an addFK method where I can specify the local columns to be used in the Foreign Key so the additional column is not created?