Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Any way to call MS SQL user-defined function directly?

51 views
Skip to first unread message

Keith Marbach

unread,
Sep 5, 2001, 4:39:05 PM9/5/01
to
Is it possible, using ADO, to call MS SQL user-defined functions from my D6
app?
Or do I need to call stored procedures?


Andy Mackie

unread,
Sep 6, 2001, 4:49:29 AM9/6/01
to
Yes, you can. Just call the function as part of a select statement. For
example, consider this (rather useless) function

CREATE FUNCTION IntegerIncrement (@integerVal int)
RETURNS int AS
BEGIN
SET @integerVal = @integerVal + 1
RETURN @integerVal
END
GO

In Delphi, have an ADODataSet with CommandType = cmdText, and the
CommandText set to
SELECT dbo.IntegerIncrement(:SomeInt) AS SomeAnswer

Manually add a parameter into the dataset's parameter list, setting the
properties as follows
Name = 'SomeInt', Attributes = [paSigned], DataType = ftInteger, Precision =
10, Size = 4, Value = Null

Execute the select statement as normal e.g.
ADODataSet1.Parameters.ParamByName('SomeInt').Value := 1;
ADODataSet1.Open;

Regards,
Andy Mackie.


Keith Marbach <kmar...@zunna.com> wrote in message news:3b968cd5_2@dnews...

Keith Marbach

unread,
Sep 7, 2001, 8:43:12 AM9/7/01
to
Thanks Andy. That's very helpful.

"Andy Mackie" <ama...@citynetworks.co.uk> wrote in message
news:3b97387b$1_1@dnews...

Barry Kelly

unread,
Sep 8, 2001, 12:26:37 AM9/8/01
to
In article <3b98c04b_2@dnews>
"Keith Marbach" <kmar...@zunna.com> wrote:

> Thanks Andy. That's very helpful.

I'd appreciate it if you'd edit down your quotes a little. Thanks.

-- Barry

0 new messages