Creating a Query

Executing this example requires that the repository contains a database with the BD identifier.

Sub Main;

Var

MB: IMetabase;

CrInf: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

Query: IQuery;

Begin

MB := MetabaseClass.Active;

CrInf := Mb.CreateCreateInfo;

CrInf.ClassId := MetabaseObjectClass.KE_CLASS_QUERY;

CrInf.Id := "NewQuery";

CrInf.Name := "NewQuery";

CrInf.Parent := Mb.Root;

MObj := Mb.CreateObject(CrInf).Edit;

Query := MObj As IQuery;

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

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

MObj.Save;

End Sub Main;

After executing the example, a new query is created in repository root. This query selects all data from table with a physical name Table_1.

See also:

Examples