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

Implement encapsulation by using C++ classes

To provide a C++ encapsulation of XP’s, the key class provided by the framework is CExtendedStoredProcedure. A specified instance of the class is created in the exporting function using the IMPLEMENT_XP macro. Then the virtual function CExtendedStoredProcedure::main is called with the SRV_PROC pointer as passed to the exported function along with the name of the exported function itself. IMPLEMENT_XP is implemented as:

#define IMPLEMENT_XP(xpName, class) \
extern "C" RETCODE __declspec(dllexport) xpName(SRV_PROC* srvproc) \
{ \
class _xp; \
return _xp.main(srvproc, #xpName); \
}


These values are then stored as member variables in the CExtendedStoredProcedure instance, so that they can be accessed from other methods of the class. To customize the functionality of the XP, various virtual functions are provided so that you can modify the standard behaviour by overriding the appropriate function in a derived class. The two key functions which a derived class should override are BOOL

 CExtendedStoredProcedure::Run() and void

 CExtendedStoredProcedure::DisplayUsage(). ‘Run’ is the method where you should implement the code specific to your XP. Returning TRUE from this function indicates that the XP ran successfully, while FALSE indicates that an error occurred. You should override ‘DisplayUsage’ to display usage information about what parameters your XP takes. The framework calls this function automatically when the XP is called with the incorrect number of parameters.


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