Monday, March 12, 2012

Extended Proc

Hi,
I have compiled a dll in delphi but I cannot use it as extended procedure(it
always returns null). Here is my source and usage in sql server:
--
library testdll;
uses
SysUtils,
Classes;
{$R *.res}
function xp_a:string;
begin
{for test}
result:='10';
end;
exports xp_a;
end.
________________________________________
_
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
exec sp_addextendedproc N'xp_a', N'testdll.dll'
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
________________________________________
_
declare @.a varchar(10)
exec master..xp_a @.a output
select @.a as output
--
Any help would be greatly appreciated.
LeilaYou can not return a string, you need to return it as an output parameter
instead, an XP always and only returns an integer.
See for examples and helper libraries:
http://www.howtodothings.com/viewar...spx?article=223
http://mastercluster.com/xproc.html
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright SQLDev.Net 1991-2005 All rights reserved.
"Leila" <Leilas@.hotpop.com> wrote in message
news:OSr6YI6JFHA.2796@.tk2msftngp13.phx.gbl...
> Hi,
> I have compiled a dll in delphi but I cannot use it as extended
> procedure(it
> always returns null). Here is my source and usage in sql server:
> --
> library testdll;
> uses
> SysUtils,
> Classes;
> {$R *.res}
> function xp_a:string;
> begin
> {for test}
> result:='10';
> end;
> exports xp_a;
> end.
> ________________________________________
_
> SET QUOTED_IDENTIFIER OFF
> GO
> SET ANSI_NULLS OFF
> GO
> exec sp_addextendedproc N'xp_a', N'testdll.dll'
> GO
> SET QUOTED_IDENTIFIER OFF
> GO
> SET ANSI_NULLS ON
> GO
> ________________________________________
_
> declare @.a varchar(10)
> exec master..xp_a @.a output
> select @.a as output
> --
> Any help would be greatly appreciated.
> Leila
>
>

No comments:

Post a Comment