IView.CreateView

Syntax

CreateView;

Description

The CreateView method creates a view in a database on the basis of available metadata.

Example

Sub Main;

Var

MB: IMetabase;

MbObj: IMetabaseObject;

CrInfo: IMetabaseObjectCreateInfo;

View: IView;

Begin

MB := MetabaseClass.Active;

CrInfo := MB.CreateCreateInfo;

CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_VIEW;

CrInfo.Id := "New_View_1";

CrInfo.Name := "New_View_1";

CrInfo.Parent := MB.Root;

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

View := MbObj As IView;

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

View.Sql := "SELECT * FROM Table_1";

View.NativeName := "New_View_1";

View. CreateView; //Creating view on database server by available metadata

MB.DeleteObject(MbObj.Key); //Removing empty object from repository

End Sub Main;

After executing the example, the view is created on a server in database.

See also:

IView