Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 UDFs inside UDF

Author  Topic 

cokebaby666
Starting Member

7 Posts

Posted - 2005-03-09 : 06:22:51
Hi,

I'm trying to figure out what I'm doing wrong with my function. To date, I can write a function that takes input parameters which are used to filter data (to say a certain date range) and return that as a table. easy peasey. Now that I'm trying to use that function inside another, i'm getting problems.
I give the same input parameters to the 'encapsulating' function for want of a better word, and try and pass them inside my
return(
select ...) statement.
The current syntax I have is like this:

Create EncapsulatingFunction(@VarA datetime,@Varb Datetime)
returns table
as
return(
select F.FieldA, F.FieldB
from FilterFunction(@VarA,@VarB) F
)
there's some joining and stuff going on but you get the idea. The code is failing with the error:
"The request for procedure 'FilterFunction' failed because 'FilterFunction' is a function object."

I was under the impression that this was the whole point of UDFs!!
Your thoughts, please!

nr
SQLTeam MVY

12543 Posts

Posted - 2005-03-09 : 06:31:08
this seems to work

Create function a(@VarA datetime,@Varb Datetime)
returns table
as
return(
select a= 1, b = 1
from sysobjects)
go

create function b(@VarA datetime,@Varb Datetime)
returns table
as
return(
select a,b
from a(@VarA,@VarB) F
)
go


select * from b('20050101','20050101')


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

cokebaby666
Starting Member

7 Posts

Posted - 2005-03-09 : 06:42:31
My mistake, just got it working. Had a field left in that had been deleted from a table. Sorry for wasting your time.
Go to Top of Page
   

- Advertisement -