Question about user-defined functions 
Author Message
 Question about user-defined functions

I have a function defined as:
----------------------------
CREATE FUNCTION function()


(

i_ID int NOT NULL,

i_Count int NOT NULL

)

AS

BEGIN

...

RETURN

END

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

Doing this works fine:

------------------------
 select * from function()
------------------------
but this does not:

------------------------
 UPDATE Table01
 SET Table01.i_Count = function().i_Count
 WHERE Table01.i_ID = function().i_ID
------------------------

I get the following error message:
------------------------------------------------
Server: Msg 195, Level 15, State 10, Line 2
'function01' is not a recognized function name.

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

If anyone can shed some light into this problem, I'd appreciate it ahead of
time.  Thanks

-H-



Wed, 29 Oct 2003 04:04:52 GMT
 Question about user-defined functions

Howard,

Haven't used a function in this regard yet but I believe it should work like
this:

 UPDATE Table01
 SET Table01.i_Count = b.i_Count FROM Table01 INNER JOIN dbo.Function() AS b
ON Table01.FK = b.FK

And you might want to look at the examples of Functions returning a table in
booksonline to fix your function.

--
Andrew J. Kelly
Targitmail.com


Quote:
> I have a function defined as:
> ----------------------------
> CREATE FUNCTION function()


> (

> i_ID int NOT NULL,

> i_Count int NOT NULL

> )

> AS

> BEGIN

> ...

> RETURN

> END

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

> Doing this works fine:

> ------------------------
>  select * from function()
> ------------------------
> but this does not:

> ------------------------
>  UPDATE Table01
>  SET Table01.i_Count = function().i_Count
>  WHERE Table01.i_ID = function().i_ID
> ------------------------

> I get the following error message:
> ------------------------------------------------
> Server: Msg 195, Level 15, State 10, Line 2
> 'function01' is not a recognized function name.

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

> If anyone can shed some light into this problem, I'd appreciate it ahead
of
> time.  Thanks

> -H-



Wed, 29 Oct 2003 04:23:25 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. call a user defined function from another user-defined function

2. A user defined function question

3. user defined function question

4. Question on user defined function (SQL Server 2000)

5. Newbie questions on User-defined functions in SQL server

6. Question on user defined function (SQL Server 2000)

7. User Defined Function Question

8. user-defined function client server question

9. questions on user-defined function

10. User defined function question

11. more question about adding values from user defined function

12. User-defined function question


 
Powered by phpBB® Forum Software