ITableForeignKeys.RemoveByKey

Fore Syntax

RemoveByKey(ForeignKeyKey: Integer): Boolean;

Fore.NET Syntax

RemoveByKey(ForeignKeyKey: uinteger): boolean;

Parameters

ForeignKeyKey. Key of the external key to be removed.

Description

The RemoveByKey method removes an external key from the collection by its key.

Comments

The ITableForeignKeys.Remove method is used to remove the key by its index.

Fore Example

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.

Fore.NET Example

Executing the example requires that the repository contains a table with the TABLE_L identifier.

Imports Prognoz.Platform.Interop.Db;

[STAThread]
Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    Table: ITable;
    FKeys: ITableForeignKeys;
    Key: ITableForeignKey;
Begin
    mb := Params.Metabase;
    Table := mb.ItemById["TABLE_L"].Edit() As ITable;
    FKeys := Table.ForeignKeys;
    If FKeys.Count > 0 Then
        Key := FKeys.Item[FKeys.Count - 1];
        System.Diagnostics.Debug.WriteLine(Key.Name);
        System.Diagnostics.Debug.WriteLine(FKeys.RemoveByKey(Key.Key));
    End If;
    (Table As IMetabaseObject).Save();
End Sub;

After executing the example the last external key is removed from the TABLE_L table.

See also:

ITableForeignKeys