greetings Likvod Systems has been creating bespoke software for the water industry since 1995. The programs are tailor-made to suit your requirements.

SQL Stored Procedures and Delphi

My latest project, another Regional Telemetry System upgrade, involves a Delphi front end which displays a tree view representing the structure of a site. It interfaces to SQL Server, which provides all of the data, and all of the transactions between the database and the front end use stored procedures. To simplify the calling of the procedures, I created a descendent of the TAdoStoredProcedure, with methods for InitName, AddParam, IntParam and OutParam. So the code becomes:

Getter.InitName := 'Live.sp_ui_get_site_info';
Getter.Addparam ('@SiteName', fSitename);
Getter.IntParam ('@Switch', 1);
Getter.ExecProc;

This works fine for normal procedures, which return quickly. For slower ones, I wanted to call the procedure asynchronously. There are three options: you can set the executeOptions to eoAsyncFetch, eoAsyncExecute or eoAsyncFetchNoBlocking. I have not found that these work very well. The only one that does is the eoAsyncExecute. So I use:

Getter.InitName := 'Live.sp_ui_rebuild_all_sites';
Getter.ExecuteOptions := [eoAsyncExecute];
Getter.Open;

Admittedly, it doesn’t actually return a proper dataset, but it does fire the ExecuteComplete event, and I use that to fetch the data if required.

Written by Bob Evens

Bob Evens is the Managing Director of Likvod Systems Ltd, and also serves as its principal engineer. He has a wide base of experience, having studied electrical engineering at Bristol University, and worked for a major supplier of Telemetry systems for twelve years. He programs in Delphi, Pascal, Sercal, Assembler and the odd bit of C and C++. He is also a qualified psychiatric nurse, and leads a local church congregation in Worksop.


One response to “SQL Stored Procedures and Delphi”

  1. Thorsten Wittekopf says:

    Dear Bob,

    have you ever received an answer? I have got the same problem.

    Greetings
    Thorsten

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.