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

MS SQL Server 7.0/2000

Extended Stored Procedure component for Delphi

A Better Way To Write Your Own Extended Stored Procedures



Table of content

People say...
Thank you for the component — it works fine.
Winfried Schöttler (Cologne, Germany)
It helped me to save time and nerves.
Harald Peki (Wels, Austria)
Much easier to write extended procedures.
Anatoly Korobkov (Moscow, Russia)
A great time saver.
Brad Couper (Gold Coast, Australia)

Awards/Listed At:
5 of 5 star rated by Shareup.com Freeware and shareware downloads 5 of 5 star rated by BrotherSoft.com 4 of 5 Gold Disk from GlobalShareware.com Listed at TopShareware.com

Component feature overview

Feature Description
Input/Output Parameters
  • Allowed all SQL datatypes which are listed below (except BLOBs)
  • Number, order, and parameters' datatypes can vary even for a particular procedure
Output Recordsets
  • Allowed all SQL datatypes which are listed below (include BLOBs)
  • An arbitrary number of recordsets can be returned from a procedure
Access to
I/O Parameters
and Recordset Fields
Either by the index or by the name, by use familiar properties such as AsString, AsInteger, AsCurrency, etc.
For example:

myXProc.Fields[0].AsInteger := 2*myXProc.Params.ByName('@IntVal').AsInteger;
SQL Datatypes
  • bigint (recoginzed as numeric)
  • binary
  • bit
  • datetime
  • float
  • int
  • money
  • numeric or decimal (see TxpItem.AsNumeric property for details)
  • nvarchar
  • varbinary
  • varchar
SQL BLOB Datatypes
  • image
  • ntext
  • text
Note: SQL Server 7.0 doesn't supported SELECT INTO/INSERT of text/ntext/image fields from the extended procedure recordsets while SQL 2000 (and later) does.
Thread Safety The component itself is a threadsafe (but your code should be a thread safe too).
Small size of DLL Compiled DLLs are of small size (since huge Classes.pas and DB.pas aren't used by the component).
Easy To Install This component does not have to be installed into the Delphi Component Palette. Just copy 2 files into any appropriate directory.
Reliability A real world code: it works as a part of the complex accounting system, 7 days a week, 24 hours a day

Pure ODS API compared with the Component

Why the Component is much more handy than pure ODS API
Thing to do Using ODS API Using Component
Easy to start, easy to use – No
You have to rewrite much of ODS code to match to specifics of every new procedure.
+ Yes
The component offers to you a clear and familiar Delphi's class idea.
You have to do only your task – No
You have much more things to implement, to control and to care about with pure ODS API.
+ Yes
The component isolates you from the ODS 'housekeeping'. You're saving your time.
No need to handle I/O parameters, determine I/O datatypes, produce recordsets, and manage memory buffers — manually – No
You have to do that everytime when you write every particular procedure.
+ Yes
The component transparently does it for you.
No need to debug your ODS code and resolve it's API function specifics – No
You should always to check the flow of your code.
+ Yes
The component has been good tested with real world applications.
Only two minor bugreports from the respective customers since the first sale!

Simple Samples

Delphi code


File xprocdemo.dpr contains two of Extended Stored Procedures with the same functionality. They are both listed here.
Function listed first uses the TXProc component, and function listed next uses only pure Open Data Services API.

Let's see how it looks!
[+] Listing #1: Using the TXProc component. Clear and short.
[+] Listing #2: Using pure Open Data Services API. Complicated and ambigous.

SQL scripts

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

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

Debug in Delphi

  • Install SQL 7.0/2000 on your workstation (or install Delphi on workstation where SQL Server is installed).
  • Register your procedure on SQL Server.
  • In Delphi, select from main menu Run -> Run Parameters.
  • In the Host Application field, specify a pathname to your SQL Server executable (sqlservr.exe). For SQL 7.0, this is enough. For SQL 2000, in the Parameters field specify a command line parameter "-sYOUR_SQL_NAME", where YOUR_SQL_NAME is the name assigned to your SQL Server during the installation.
  • Set breakpoints in your Delphi code and run project. SQL Server will start as a console application. You can execute your procedure from Query Analyzer and trace code in Delphi.
  • To exit application, press Ctrl+Pause in the SQL Server console window.

    Component reference

    [+] Types

    TXProc, class

    Create an instance of the TXProc to work with Extended Stored Procedure. TXProc type has an alias named TXtendedProc.
    [+] Properties
    [+] Methods

    TxpItems, class

    A base class both for Params and Fields collections.
    [+] Properties
    [+] Methods

    TxpParams, class

    Class TxpParams is derived from TxpItems. It is used to access to I/O procedure parameters.

    Class TxpParams has only overriden the TxpItems's constructor and destructor.
    When instantiating TXProc, then it's constructor creates TxpParams, which constructor, in turn, reads data and attributes of the I/O parameters.
    When TXProc destroys, then it calls to TxpParams 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.

    TxpFields, class

    Class TxpFields is derived from TxpItems. Fields are used to create and return recordsets from the procedure.
    [+] Properties
    [+] Methods

    TxpItem, class

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


    Download Demo

    Demo PackageDownload Now!
    • Manual in HTML (is what you currently read)
    • Microsoft Open Data Services API unit (MSODSAPI.pas, a Srv.h translation)
    • Component unit interface part, no full source code (XProc.int)
    • Component compiled demo units for Delphi 5,6,7 (XProc.dcu5, XProc.dcu6, and XProc.dcu7 respectively) with limited demo functionality: only parameters and fields of SQL datatype int can be accessed (see TxpItem.AsInteger property); supported recordsets; not supported Output parameters
    • Sample project (source code, compiled DLL, test T-SQL script)
    • License Agreement
    xprocdemo.zip (80K)

    Order Products

    Products To Order Volume Discount Prices Purchase
    XProc.pas - component for Delphi 5,6,7
    (full functional, WITH FULL SOURCE CODE)
    Show Order Now
    DCUs for Delphi 5,6,7 (full functional, NO SOURCE) Show Order Now
    DCU for Delphi 5 (full functional, NO SOURCE) Show Order Now
    DCU for Delphi 6 (full functional, NO SOURCE) Show Order Now
    DCU for Delphi 7 (full functional, NO SOURCE) Show Order Now

    License

    Products are 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 Offers — Free of Charge
    Order any product from listed above and receive for FREE:
  • File Read/Write extended stored procedures — full source code for Delphi and example T-SQL scripts
  • MC FolderJump context menu extension for Windows Explorer — the registration key
  • License

    The bonus products are licensed for the same number of licenses as for the master product.
    For example, when order 3 copy of the XProc component, then receive 3 licenses for "File Read/Write procedures" and "MC FolderJump" as well.


  • About the author
    This software has been developed by me, Leonid 'MC' Belousov.
    I have 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