PROCEDURES AND FUNCTIONS IN .NET LANGUAGES T-SQL procedures may have default values for parameters, and this is true for procedures implemented with methods. In addition, a single method may be used to implement more than one procedure. This makes it possible to have several procedures, each with a different default value for a parameter, all implemented by the same CLR method. The following SQL script creates the PassBack3 and PassBack4 procedures, both implemented with the PassBackmethod, using a default value for valueIn. CREATE PROC PassBack3(@valueIn INT = 5, @valueOut INT OUTPUT) as EXTERNAL NAME procedures.[Procedures.Parameters].PassBack CREATE PROC PassBack4(@valueIn INT = 7, @valueOut INT OUTPUT) as EXTERNAL NAME procedures.[Procedures.Parameters].PassBack The following SQL script executes the PassBack3 procedure, using a default parameter. DECLARE @i int SET @i = 4 EXEC PassBack3 DEFAULT, @i OUTPUT PRINT @i GO 9 CLR types that correspond to a SqlType(see Table 3-1) can also be used as types for parameters in a stored procedure. The following code is a different version of the PassBack method, rewritten to make use of int instead of SqlInt32. public static void PassBack2(int valueIn, ref int valueRef) { // pass in + out to out valueRef += valueIn; } In summary, procedures implemented using a CLR language can be used in the same way as procedures implemented using T-SQL. They can have parameters passed by value or reference and passed by position or name. A parameter can have a default value, and the same CLR implementation can be used for more than one procedure, each having different default values. CLR implementations that use SqlType parameters must be sure to check for parameters values that are representing null.

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Bookmark the permalink.

Comments are closed.