WinAPI complexity to Delphi simplicity
 MC Programming Libraries
Home: More Products Ask Your Question! Look at version for Delphi  

MS SQL Server 7.0/2000

Extended Stored Procedure class for Visual C++

A Better Way To Write Your Own Extended Stored Procedures



Table of content

 

Awards/Listed At:
5 of 5 star rated by BrotherSoft.com 5 of 5 star rated by ShareUp.com Listed at TopShareware.com 4 of 5 Gold Disk from GlobalShareware.com

Class feature overview

  • Supported datatypes for input/output procedure parameters are: bit, datetime, float, int, money, varbinary, varchar, nvarchar. Datatype numeric (decimal) is also supported but with the limited precision.
    Note: SQL Server 2000 introduces a new datatype — bigint. It is recognized by Xp as numeric (decimal).
  • Supported datatypes for recordset fields are the same as for the I/O parameters. Plus supported BLOB fields such as text, ntext, and image.
    Note: SQL Server 7.0 doesn't support returning of text/ntext/image fields from the Xp recordset while SQL 2000 (and later) does.
  • Producing of arbitrary number of recordsets.
  • Access to I/O parameters and recordset fields either by the index and by the name. Number and datatypes of parameters may vary even for the particular procedure!
  • Access to values of the Parameters and Fields using simple methods such as GetInt(), SetMoney(), etc.
  • Small size of the compiled DLL since the CXProc class doesn't using huge MFC Library. Sample DLL takes about 56KB in VC++ 6.
  • It is thread safe (but your code should be thread safe too).

Simple Sample

VC++ code

This code deals with two optional I/O parameters (first them is varchar and second is int), modifies first (when present), and then creates a recordset of 3 columns: int, datetime, and image.

[+] Let's see how it looks!

SQL scripts

Place the xprocdemovc.dll into the SQL Server's BINN\ directory, then open and execute the xprocdemovc.sql script from the Query Analyzer.
Here is described step-by-step what the script does.

[+] Register and unregister the extended procedure
[+] Test script results

Compiling in VC++

  • Ensure ODS API header (Srv.h) and it's library (opends60.lib) are up-to-date (from MSSQL 2000);
  • Include xproc.h into your DLL project;
  • Add opends60.lib and xproc.lib to Settings (Alt+F7) - Link - Object/library modules.

    Debug in VC++

  • Install SQL 7.0/2000 on your workstation (or install VC++ on workstation where SQL Server is installed).
  • Register your Xp with SQL Server.
  • In VC++ 6, from main menu Project -> Settings (or Alt+F7). Select Debug tab, Category: General.
  • In the Executable for debug session field, specify a pathname to your SQL Server executable (sqlservr.exe). For SQL 7.0, this is enough. For SQL 2000, in the Program arguments field specify a command line parameter "-sYOUR_SQL_NAME", where YOUR_SQL_NAME is the name you assign to SQL Server during the installation.
  • Set breakpoints in your VC++ code and run project. SQL Server will start as a console application. You can execute your Xp from Query Analyzer and trace code in VC++.
  • To exit application, press Ctrl+Pause in the SQL Server console window.

    CXProc class reference

    [+] Types

    CXProc

    Create an instance of the CXProc to work with Extended Stored Procedure.
    [+] Member Functions

    CxpItems

    A base class both for Params and Fields collections. It is maintains a collection of CxpItem*.
    [+] Member Functions

    CxpParams

    Class CxpParams is derived from CxpItems. It is used to access to I/O procedure parameters.

    Class CxpParams has only overriden the CxpItems's constructor and destructor.
    When instantiating CXProc, then it's constructor creates CxpParams, which constructor, in turn, reads data and attributes of the I/O parameters.
    When CXProc destroys, then it calls to CxpParams destructor, which, in turn, sends data of output parameters back to SQL Server.

    Note: Parameters of the particular procedure are not fixed either by their number, datatype, and position. Any number of parameters, of any valid datatypes, and in any order can be passed to the same procedure. This gives us a kind of great flexibility, but here is also our responsibility to handle the input parameters properly.

    CxpFields

    Class CxpFields is derived from CxpItems. Fields are used to create and return recordsets from the Xp.
    [+] Member Functions

    CxpItem

    A base class for the items of the Params and Fields collections. Provides basic properties and methods to read and write data values.
    [+] Member Functions

    Download Demo

    Demo PackageDownload Now!
    • Manual in HTML (is what you currently read)
    • Class header file, XPROC.H (no full source code)
    • Sample project (source code, compiled DLL, test T-SQL script)
    • License Agreement
    xprocdemovc.zip (45K)

    Order Product

    Product To Order Volume Discount Prices Purchase
    XPROC.CPP - Extended stored procedure class for Visual C++ 6,7
    (full functional, WITH FULL SOURCE CODE)
    Show Order Now

    License

    The product is licensed on per-developer basis.
    For example, team of 3 developers of extended stored procedures needs to purchase 3 copies of the product.

    Delivery

    By the email in the short time since you have to order.

    Bonus Offers

    Special Offer — Free of Charge
    Order the CXProc class NOW and receive for FREE the registration key for the
    MC FolderJump context menu extension for Windows Explorer

    License

    The bonus product is licensed for the same number of licenses as for the master product.
    For example, when order 3 copy of the CXProc class, then receive 3 licenses for "MC FolderJump" as well.


  • About the author
    This software has been developed by me, Leonid 'MC' Belousov.
    I'm having over 10 years of experience in the field of Graphical User Interface development, Database and Systems programming for Microsoft Windows.
      Copyright © 1996-2003 Leonid 'MC' Belousov