Call now: (800) 766-1884  



 Home


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA



 Articles
 Services
 SQL Server Scripts
 Scripts Menu



 

 

 

   
  SQL Server Tips by Gama and Naughter


 

The Object Model

 

As described earlier in the book, the ODS API can be broken down into a number of areas. The object model we develop should make it easier to navigate by rationalizing this API. The object model should represent the parameters as an array with each parameter represented by an item in this array. This mirrors the way command line arguments are provided in Windows Script when you run a .JS or .VBS file from the Windows Shell. In Windows Script you can access these command line arguments as a standard COM collection using the following JScript code:

 

if (WScript.Arguments.length < 1)

{

  WScript.Echo("This script requires at least one command line argument ");

  WScript.Quit(1);

}

 

Each item in the proposed parameters array could then contain properties which encapsulate the information as returned from the ODS function “srv_paraminfo”. In addition we can have methods of this parameter object, which return if the parameter is an INPUT or OUTPUT parameter. The parameters collection should also allow you to locate the index of a named parameter via the “srv_paramnumber” ODS function.

 

We should encapsulate the entire ODS set of functions in another COM object just like the intrinsic “WScript” object does for shell scripts. For example if we wanted to call “srv_sendmsg” to return an error message back to SQL we could use the following JScript snippet:

 

If (SQL.Parameters.length < 4)

{

  SQL.SendErrorMsg("This XP requires at least 4 parameters");

.

.

.

 

The “SQL” object would be our equivalent to the “WScript” object and the “SQL.Parameters” code refers to the parameters array we have already mentioned.

 

Ok, enough with the theory, lets start putting the code together.

 

Initial Creation

 

We need to implement the object model using COM in a standard Windows DLL, which also operates as an Extended Stored Procedure. We have already demonstrated most of this idea in the XP_SERVERREACHABLE chapter. We follow

The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter

 http://www.rampant-books.com/book_2005_2_sql_server_external_procedures.htm  

 

Burleson Consulting Remote DB Administration


 

 


 

 

 

 

 
Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.
 


Burleson Consulting
SQL Server database support

 

Copyright © 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter