RemoveByKey(ForeignKeyKey: Integer): Boolean;
ForeignKeyKey. Key of the external key to be removed.
The RemoveByKey method removes an external key from the collection by its key.
The ITableForeignKeys.Remove method is used to remove the key by its index.
Executing the example requires that the repository contains a table with the TABLE_L identifier.
Add links to the Metabase, Db system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Table: ITable;
FKeys: ITableForeignKeys;
Key: ITableForeignKey;
Begin
mb := MetabaseClass.Active;
Table := mb.ItemById("TABLE_L").Edit As ITable;
FKeys := Table.ForeignKeys;
If FKeys.Count > 0 Then
Key := FKeys.Item(FKeys.Count - 1);
Debug.WriteLine(Key.Name);
Debug.WriteLine(FKeys.RemoveByKey(Key.Key));
End If;
(Table As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the last external key is removed from the TABLE_L table.
See also: