Kind: ProcedureKind;
The Kind property determines the type of created object: function or procedure.
Executing the example requires a repository database with the BD identifier. Server contains a table with the Table_1 physical name.
Sub UserProc;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
Proc: IProcedure;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_PROCEDURE;
CrInfo.Id := "New_Func_1";
CrInfo.Name := "New_Func_1";
CrInfo.Parent := MB.Root;
Proc := MB.CreateObject(CrInfo).Edit As IProcedure;
Proc.Database := Mb.ItemById("BD").Bind As IDatabase;
Proc.Kind := ProcedureKind.Function_;
Proc.Text("ORCL") :=
"Return number" + #13 + #10 +
"As Param number;" + #13 + #10 +
"Begin" + #13 + #10 +
"Select Count(*) Into Param From Table_1;" + #13 + #10 +
"Return Param;" + #13 + #10 +
"End;";
Proc.NativeName := "New_Func_1";
(Proc As IMetabaseObject).Save;
End Sub UserProc;
After executing the example, the new function is created in repository root. On executing the function, the number of records in the Table_1 table is returned as a value.
See also: