CreateProcedure([Options: Integer = 0]);
Options. Reserved parameter.
The CreateProcedure method creates a procedure in the database on the basis of available metadata.
A physical procedure created on the DB server corresponds to each repository object Procedure. The procedure is automatically created on DB server on creating and saving repository procedure.
This method creates a physical procedure on server based on existing description of the repository procedure. Using this method is relevant, if there is no need to create corresponding object in repository.
NOTE. The method is automatically called on creating and saving a repository procedure.
Example of creating a procedure in repository:
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;
MObj: IMetabaseObject;
CrInfo: IMetabaseObjectCreateInfo;
Proc: IProcedure;
Begin
MB := MetabaseClass.Active;
//Information for object creation
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_PROCEDURE;
CrInfo.Id := "New_Proc_1";
CrInfo.Name := "New_Proc_1";
CrInfo.Parent := MB.Root;
//Creating temporary object. The procedure is saved after the parameters are changed
MObj := MB.CreateObject(CrInfo).Edit;
Proc := MObj As IProcedure;
Proc.Database := Mb.ItemById("BD").Bind As IDatabase;
Proc.Text("ORCL") :=
"As" + #13 + #10 +
"Begin" + #13 + #10 +
"Insert Into Table_1 values(15,'New');" + #13 + #10 +
"End;";
Proc.NativeName := "New_Proc_1";
//Saving repository procedure
//Procedure is automatically created on database server at saving
MObj.Save;
End Sub UserProc;
After executing the example, a new procedure is created in repository root. Corresponding table is created on database server when the repository object is saved.
Example of creating a procedure on database server without creating corresponding repository object:
Executing this example requires a repository database with the BD identifier. Server contains a table with the Table_1 physical name.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
CrInfo: IMetabaseObjectCreateInfo;
Proc: IProcedure;
Begin
MB := MetabaseClass.Active;
//Information for object creation
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_PROCEDURE;
CrInfo.Id := "New_Proc_1";
CrInfo.Name := "New_Proc_1";
CrInfo.Parent := MB.Root;
//Creating temporary object. The procedure is saved after the parameters are changed
MObj := MB.CreateObject(CrInfo).Edit;
Proc := MObj As IProcedure;
Proc.Database := Mb.ItemById("BD").Bind As IDatabase;
Proc.Text("ORCL") :=
"As" + #13 + #10 +
"Begin" + #13 + #10 +
"Insert Into Table_1 values(15,'New');" + #13 + #10 +
"End;";
Proc.NativeName := "New_Proc_1";
//Creating physical procedure on DB server
//by existing description of repository procedure
Proc.CreateProcedure;
End Sub UserProc;
After executing the example, a new procedure is created on server in database.
See also: