Board index » delphi » MS SQL Server Extended Stored Procedures and the Open Data Services API

MS SQL Server Extended Stored Procedures and the Open Data Services API

Good afternoon,
I am attempting to create a dll with Delphi that will be called from an
extended stored procedure residing in MS SQL server.  The dll is called just
fine.  However, I appear to be having problems receiving the parameters from
the stored procedure.  The call to srv_rpcparams always returns -1.  If I
try to retrieve parameter information, it is not there.   So, even ignoring
this problem, I do not get anywhere.  I have stripped out most of the code I
am working with to attempt to get to the root of the problem.  Here is the
Pascal code:

=========== Unit with API declarations ===========
unit paramCountOnly;

interface
uses Windows;

type
  Int32 = longint;

type
  PSRV_PROC = pointer;
  SRVRETCODE = Int32;        { SUCCEED or FAIL }

function srv_rpcparams(
           srvproc: PSRV_PROC): integer; far; cdecl;

implementation

function srv_rpcparams;      external 'opends60.dll' name 'srv_rpcparams';

============= dll unit ============
library xps;

uses
  Windows,
  SysUtils,
  Classes,
  paramCountOnly in 'paramCountOnly.pas';

function xp_checkParamCount(srvproc: PSRV_PROC): SRVRETCODE;
var
  params : integer;
  loggingFile : TextFile;
begin
  params := srv_rpcparams( srvproc );   // this always returns -1
  AssignFile(loggingFile, 'c:\temp\xplog0.txt');
  rewrite( loggingFile );
  writeln( loggingFile, 'xp_incbyone1: params = ' + inttoStr( params ) ); //
This always prints -1
  Flush( loggingFile );
  CloseFile( loggingFile );
end

===========  creating the XP ============
use master
go
sp_addextendedproc xp_checkParamCount, 'xps.dll'

============= calling the XP ============
declare @ret varchar(50)
declare @var1 int
set @var1 = 1
exec @ret=xp_checkParamCount @var1 OUTPUT
select @var1 AS OUTPUT_Parameter1,
       @ret AS ret

Any ideas what I am doing wrong?

Thanks in advance,
Scott

 

Re:MS SQL Server Extended Stored Procedures and the Open Data Services API


Quote
"Scott Vickery" <sco...@virtual-systems.com> wrote in message <news:3e77b0c8$1@newsgroups.borland.com>...
> Good afternoon,
> I am attempting to create a dll with Delphi that will be called from an
> extended stored procedure residing in MS SQL server.  The dll is called just
>   params := srv_rpcparams( srvproc );   // this always returns -1

Take a look at http://www.bramc.ru/soft/xproc.html
This is a shareware Delphi Ext Proc component. It handles the input
parameters and does many other things fairly well.

---
Best regards,
Leonid.

Re:MS SQL Server Extended Stored Procedures and the Open Data Services API


Perhapse:

Quote
> function xp_checkParamCount(srvproc: PSRV_PROC): SRVRETCODE;

Is missing an "stdcall" ??

Good luck,
Stephane

Re:MS SQL Server Extended Stored Procedures and the Open Data Services API


I found some useful code here today: http://www.bramc.ru/soft/xproc.html

--

Mike Collier
www.adoanywhere.com

Quote
"Scott Vickery" <sco...@virtual-systems.com> wrote in message

news:3e77b0c8$1@newsgroups.borland.com...
Quote
> Good afternoon,
> I am attempting to create a dll with Delphi that will be called from an
> extended stored procedure residing in MS SQL server.  The dll is called
just
> fine.  However, I appear to be having problems receiving the parameters
from
> the stored procedure.  The call to srv_rpcparams always returns -1.  If I
> try to retrieve parameter information, it is not there.   So, even
ignoring
> this problem, I do not get anywhere.  I have stripped out most of the code
I
> am working with to attempt to get to the root of the problem.  Here is the
> Pascal code:

> =========== Unit with API declarations ===========
> unit paramCountOnly;

> interface
> uses Windows;

> type
>   Int32 = longint;

> type
>   PSRV_PROC = pointer;
>   SRVRETCODE = Int32;        { SUCCEED or FAIL }

> function srv_rpcparams(
>            srvproc: PSRV_PROC): integer; far; cdecl;

> implementation

> function srv_rpcparams;      external 'opends60.dll' name 'srv_rpcparams';

> ============= dll unit ============
> library xps;

> uses
>   Windows,
>   SysUtils,
>   Classes,
>   paramCountOnly in 'paramCountOnly.pas';

> function xp_checkParamCount(srvproc: PSRV_PROC): SRVRETCODE;
> var
>   params : integer;
>   loggingFile : TextFile;
> begin
>   params := srv_rpcparams( srvproc );   // this always returns -1
>   AssignFile(loggingFile, 'c:\temp\xplog0.txt');
>   rewrite( loggingFile );
>   writeln( loggingFile, 'xp_incbyone1: params = ' + inttoStr( params ) );
//
> This always prints -1
>   Flush( loggingFile );
>   CloseFile( loggingFile );
> end

> ===========  creating the XP ============
> use master
> go
> sp_addextendedproc xp_checkParamCount, 'xps.dll'

> ============= calling the XP ============
> declare @ret varchar(50)
> declare @var1 int
> set @var1 = 1
> exec @ret=xp_checkParamCount @var1 OUTPUT
> select @var1 AS OUTPUT_Parameter1,
>        @ret AS ret

> Any ideas what I am doing wrong?

> Thanks in advance,
> Scott

Other Threads