« Home     About     @Contact

Extended Stored Procedures in Delphi? That's simple!

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

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 Delphi or C/C++ (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 Delphi The better way: a Delphi component 

Here is a Delphi class TXProc that hides all of that jazz from the developer and just exposes familiar Delphi methods and properties. It is compatible to Delphi versions 5, 6, 7, 2005 and 2006.

No more dozens of srv_describe, srv_paramsetoutput, srv_rpcparams, srv_paraminfo, etc!

Just with myXProc do Fields[0].AsInteger := Params.ByName('@IntVal').AsInteger.

This is a real world component: It works as a part of a complex accounting system, 7 days a week, 24 hours a day.


5 Example Delphi Extended Stored Procedure Example 

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

  • Creates an TXProc object,
  • Reads the number of input parameters,
  • Defines a recordset column, and
  • Handles possible ecxeptions


6 Component's features 

The component 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
  • Demo DCU for Delphi 5,6,7
  • Complete reference manual in *.CHM format

Note DCUs have limited demo functionality:

  • Only parameters and fields of SQL datatype int can be accessed
    (see TxpItem.AsInteger property in the Manual)
  • Output parameters are not supported
  • Recordsets are supported



7 Order Buy component source code 

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


Component source code (full version) for Delphi 5,6,7,2005 and 2006

Volume Discount Prices: Show

BUY NOW!

Bonus: Includes full source code of xpCompressUtils


Show our Privacy Policy and Order Processing information.

* Applies to payments made by credit or debit cards.

Customers say...

“Thank you for the component — it works fine.”

Winfried Schoettler
(Cologne, Germany)

“It helped me to save time and nerves.”

Harald Peki
(Wels, Austria)

“It certainly makes creating XPs much easier.”

Larry Carter
(Hubbard, Oregon, USA)

“A great time saver!”

Brad Couper
(Gold Coast, Australia)



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-2008 MasterCluster.com