field("col_name(tableid, fokey16)", String.class),
field("object_owner_id(tableid)"))
.from(Sysreferences.SYSREFERENCES)
.fetch()) {
TableDefinition referencingTable = getTable(getSchema(), record.getValueAsString("fk_table"));
if (referencingTable != null) {
for (int i = 0; i < 16; i++) {
if (record.getValue(i + 3) == null) {
break;
}
String foreignKeyName = record.getValueAsString("fk");
String foreignKeyColumnName = record.getValueAsString(i + 3);
String uniqueKeyName = record.getValueAsString("pk");
ColumnDefinition column = referencingTable.getColumn(foreignKeyColumnName);
relations.addForeignKey(foreignKeyName, uniqueKeyName, column, getSchema());
}
}
}
}