« Home     About     @Contact

Extended Stored Procedures in VC++? That's simple!

A better way to write your own Extended Stored Procedures for SQL Server in VC++

1 What are Extended Stored Procedures? 

Extended Stored Procedure is a special function packaged in a DLL.

Extended stored procedures for SQL Server can be written either in VC++ or Delphi (or any other compiler which supports function export - VB and C# can't unless of use SQL Server 2005). And yes, all the WinAPI can be used there.

Like regular T-SQL stored procedures (or .NET extended stored procedures for SQL Server 2005), they can accept input/output parameters and produce recordsets.

The great difference is that they can accept a variable list of input parameters of different datatypes! So, actual number of parameters and their datatypes can be determined by extended stored procedure at runtime.

2 What are they good for? 

Extended Stored Procedures are good for:

  • Tasks that are hard or impossible to implement in Transact SQL (for example, file system access, or use of complex external APIs such as cryptographics or internet access)
  • Stored procedures that must be called from user defined functions (UDF)
  • Business logic to be hidden from others.


3 Is that easy to write extended stored procedures? 

Although giving these benefits, the native Extended Stored Procedures API (former Open Data Services API) is rather complex in use.

It requires too much "housekeeping" work from the developer: manage memory buffers, handle I/O parameters, determine I/O datatypes, describe and produce recordsets, etc, etc, etc...

This, in turn, may require often debug.


Is there a better way?



4 Extended Stored Procedure for VC++ The better way: a VC++ class 

Here is a VC++ class CXProc that hides all of that jazz from the developer and just exposes methods and properties.

It is compatible to VC++ 6 and 7.

No more dozens of srv_describe, srv_paramsetoutput, srv_rpcparams, srv_paraminfo, etc!
Just CXProc xproc(srvproc); CxpFields& fd = xproc.Fields(); fd[0].SetInt(123);


5 Example VC++ Extended Stored Procedure Example 

[+] This example does the following (click here to show/hide):

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.



6 Class features 

This class supports the following datatypes for I/O Parameters and Recordset Fields:
  • bigint (recoginzed as numeric)
  • binary
  • bit
  • datetime
  • uniqueidentifier (TGUID in Delphi)
  • float
  • int
  • money
  • numeric or decimal
  • nvarchar
  • varbinary
  • varchar

Plus, it supports the following BLOB datatypes for Recordset Fields:

  • image
  • ntext
  • text

Maximum length of varchar/nvarchar parameters data is 4000 symbols.

An arbitrary number of recordsets can be returned from a procedure.

Note: Instead of SQL Server 2000 (and later), SQL Server 7.0 does not support SELECT INTO/INSERT of text/ntext/image fields from extended stored procedure recordsets.

Download extended stored procedure demo Download Demo (120KB)

Includes:

  • Demo DLL and its source project
  • Header source file: CXProc.h
  • Complete reference manual in *.CHM format



7 Order Buy source code 

Instant Delivery!
Receive this product immediately* right after you have made your order!


Class source code (full version) for VC++ 6 and 7

Volume Discount Prices: Show

BUY NOW!


Show our Privacy Policy and Order Processing information.

* Applies to payments made by credit or debit cards.


RELATED ITEMS

Stored Procedures for SQL Server

Access file system and Internet, use data compression and cryptography with T-SQL.

Read more...


Create your own Extended Stored Procedures!

That's easy if use wrapper classes for Visual C++ or Delphi.



SEE ALSO

Folder Jump Folder Jump.com

Let Your Fingers Rest!
Stop waste your time browsing directories!


Folder Size
FREE shell extension, adds 'Folder Size' column to Windows Explorer


Delphi Components

Internet tools, PGP SDK wrapper component, User activity detection Smart message boxes...


GlyFy.com - stock glyphs and icons for software development GlyFy.com
Quality icons, glyphs, and images for software development




Awards

5 of 5 star rated by BrotherSoft.com

Listed at TopShareware.com

4 of 5 Gold Disk from GlobalShareware.com

5 of 5 star rated by Shareup.com

Freeware and shareware downloads

5 of 5 star rated by SoftForAll.com

Copyright © 1996-2007 MasterCluster.com