ITable.AttachTable

Syntax

AttachTable(TableName: String; MakeExternal: Boolean);

Parameters

TableName is a physical name of the table that is a source of fields.

MakeExternal is the parameter defining that a table is external. If False is passed as the parameter value, table structure is updated, if True is passed, indicator of the external table is set for this table.

Description

The AttachTable method updates information about table structure in a repository, according to table structure on database server. The information about structure of fields, indexes, triggers, table constraints is updated. The method is also used to create an external table.

Example

Executing the example requires that the repository contains a database with the BD identifier. The database is set up for connection to database server, in which the table with the Table_1 physical name is contained.

Sub Main;

Var

Mb: IMetabase;

CrInfo: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

Table: ITable;

Begin

Mb := MetabaseClass.Active;

CrInfo := MB.CreateCreateInfo;

CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_EXTERNTABLE;

CrInfo.Id := "NewAttachTable";

CrInfo.Name := "NewAttachTable";

CrInfo.Parent := Mb.Root;

MObj := MB.CreateObject(CrInfo).Edit;

Table := MObj As ITable;

Table.Database := Mb.ItemById("BD").Bind As IDatabase;

Table.AttachTable("Table_1", True);

MObj.Save;

End Sub Main;

After executing the example, external tables are created in the repository root. The table refers to the table with the Table_1 physical name, stored on database server.

See also:

ITable