Diference between system and user defined functions

  • Thread starter Thread starter =?windows-1257?Q?Linas_Petkevi=E8ius?=
  • Start date Start date
?

=?windows-1257?Q?Linas_Petkevi=E8ius?=

Hallo,

For example i have a user defined function:

ALTER FUNCTION RectangleArea (@Width int, @Height int ) RETURNS int AS BEGIN RETURN ( @Width * @Height ) END


I tried to use this function in this example, but it does not works
___________________________________
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset

cn.Open CurrentProject.Connection

Set cmd.ActiveConnection = cn

cmd.CommandText = "select rectangleArea(10, 20)"

Set rs = cmd.Execute

msgbox rs.Fields(0)

__________________________________

But if i put getdate() or other system function, everything is ok. ;(( How can i solve this ?


Linas
 
Try prefixing your function with the owner name of the function. For
example, instead of writing:

select rectanglearea (1, 2)

Write instead:

select dbo.rectanglearea (1, 2)

In this example, dbo is the owner name of the function. If you are using a
no-owner account, then use the right prefix or make sure that it is created
under the dbo ownership:

Create Function dbo.RectangleArea (....)....

Also, SQL-Server should be used to retrieve datas, not to compute things
like geometrical datas. Unless when necessary to retrieve the desired
results, this kind of computing stuff should be made on the client side.

S. L.
 
Back
Top