Board index » delphi » How to write a extended stroed procedure of MS SQL 2K by Delphi

How to write a extended stroed procedure of MS SQL 2K by Delphi

 The source code make a dll file ,but it can transfer parameter to the
function xp_min by SQL Query Analyzer
example :  exec xp_min 23   , it return -2147418113.
Where I mistake

------------------------------------------

library mdll;
uses SysUtils,
       Classes , dialogs;
{$R *.RES}
function xp_min(var X : Integer): Integer; //stdcall ;//safecall
begin
xp_min := X
end;

exports
xp_min;

end.

 

Re:How to write a extended stroed procedure of MS SQL 2K by Delphi


Quote
In article <3c9dd128_2@dnews>, James_liu wrote:
>  The source code make a dll file ,but it can transfer parameter to the
> function xp_min by SQL Query Analyzer
> example :  exec xp_min 23   , it return -2147418113.
> Where I mistake

Looks like a typical calling convention mismatch. You have to use either
stdcall or cdecl, probably stdcall. Oh, and drop the Var. Whether you need
it or not depends on how you have declared the function for SQL server.
Without seeing that its impossible to say.

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Re:How to write a extended stroed procedure of MS SQL 2K by Delphi


Hi james_liu!

On Sun, 24 Mar 2002 21:12:45 +0800, "james_liu"

Quote
<james_...@ms22.url.com.tw> wrote:
> The source code make a dll file ,but it can transfer parameter to the
>function xp_min by SQL Query Analyzer
>example :  exec xp_min 23   , it return -2147418113.
>Where I mistake

>------------------------------------------

>library mdll;
>uses SysUtils,
>       Classes , dialogs;
>{$R *.RES}
>function xp_min(var X : Integer): Integer; //stdcall ;//safecall
>begin
>xp_min := X
>end;

>exports
>xp_min;

>end.

You can not make extended stored procedures like that. There is a
whole "Open Data Services" interface to communicate with SQL server
from inside of delphi. The whole thing is little similar to writing C
functions to be used in old dos Clipper.

Somebody have made a wrapper for extended stored procedures, and I
hapend to download that some time ago. It was for a MSSQL 6.5, but I
expect it to work with 2000, you would have to try.

In case you are interested to get this I have sent xps.zip for you to
attachements conference...

tomi.

Re:How to write a extended stroed procedure of MS SQL 2K by Delphi


Quote
> The source code make a dll file ,but it can transfer parameter to the
>function xp_min by SQL Query Analyzer

Check out this site - it has an article, slides and sample code to
show you how to create your SQL Server extended stored procs in
Delphi:

http://berend.gameren.nl/delphi/index.html

Marc

------------------------------------------------------------------------
Marc Scheuner                                          Software Engineer
Quest Software Canada                       Halifax, Nova Scotia, Canada
Email: marc.scheu...@quest.com                      http://www.quest.com

Other Threads