Example CLR Function and CLR Procedure
The CLRProcs sample is located in the CLRProcs folder of the Samples area installed with VistaDB. For more information on locating the samples on your computer, see Sample Projects included with VistaDB.
Basic Steps using SQL Scripts
The following steps can be taken to build just the CLR Procs assembly, and then manually load it all into the database using only Data Builder. I highly recommend you do these steps one time just to see how they are done.
- Compile the MyClrProcExport project (just compile entire solution)
- Load the SampleDB.vdb6 from the debug folder of the CLRProcSampleRunner.
- Load the AddAssemblyAndProcs.vsql5 file. Run to load the assembly and assign the functions. Also demonstrates how to update an assembly using only SQL code.
- Load the CallCLRProcs.vsql5 to see different ways of calling the functions and procedures.
- Load the RemoveAssemblyAndProcs.vsql5 to remove all of the methods and then drop the assembly.
Basic CLR Procs Steps with C# Source
The sample source code allows you to step through and look at the code calls within Visual Studio.
- Compile the MyClrProcExport project. Set a break point in the main of the CLRProcSampleRunner project (Program.cs).
- Debug the CLRProcSampleRunner as the startup project.
- Step through the following functions to each action:
- RegistrationRoutines.RegisterAssembly();
- RegistrationRoutines.RegisterAllMethodsDDA();
- RegistrationRoutines.ShowRegisteredCLRMethods();
- CallingRoutines.CallAllSQL();
- RegistrationRoutines.UnregisterAllMethodsDDA();
- RegistrationRoutines.UnregisterAssemblyDDA();
Each sample includes comments in the code to demonstrate how it works and point out key implementation notes.