Executing the example requires that the repository contains a database with the BD identifier.
Sub Main;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
Proc: IProcedure;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_PROCEDURE;
CrInfo.Id := "NewProcedure";
CrInfo. Name: = "New procedure";
CrInfo.Parent := MB.Root;
Proc := MB.CreateObject(CrInfo).Edit As IProcedure;
Proc.Database := Mb.ItemById("BD").Bind As IDatabase;
Proc.Text(Proc.Database.DriverId) :=
"As" + #13 + #10 +
"Begin" + #13 + #10 +
"For i In 1..10 Loop" + #13 + #10 +
"Insert Into Table_1(field1, field2) Values(i, i);" + #13 + #10 +
"End Loop;" + #13 + #10 +
"End;";
Proc.NativeName := "NewProc";
(Proc As IMetabaseObject).Save;
End Sub Main;
After executing the example, a new procedure is created in repository root. On executing the command ten records with the specified values of two fields are added in a cycle to the table with the physical name Table_1.
See also: