MySQL Forums
Forum List  »  Stored Procedures

Re: Stored procedure vs. function
Posted by: Andrew Gilfrin
Date: June 01, 2005 02:19AM

There is one main difference between functions and procedures.

A function must return a value and it can be only a single value. Any number of parameters can be passed in but only 1 value can be passed out. This value comming out must be done via the RETURN.

A Procedure doesn't have to return anything. But it can accept any number of parameters in and also any number of parameters out. There is no RETURN in a procedure.

At the present time functions are limited in the SQL they can use but that should be temporary. Also you can't use a procedure in an SQL statement because it doesn't return values in the same way.

To address the second part of the question, no it doesn't matter if you convert the procedure to a function, but the behaviour of the procedure needs to be such that it only returns a single value. If that is the case it would proberly be desireable to make it into a function.

Have a look at the following page which expands (only slightly) on the above.
http://mysql.gilfster.com/tutorials/funcorprocs.php

Andrew Gilfrin
------------------
http://gilfster.blogspot.com
My MySQL related Blog

http://www.mysqldevelopment.com
MySQL Stored Procedure,Trigger, View.... (Just about most things these days) Information

Options: ReplyQuote


Subject
Views
Written By
Posted
25237
June 01, 2005 12:11AM
Re: Stored procedure vs. function
20332
June 01, 2005 02:19AM
8177
June 01, 2005 03:53AM
5181
June 19, 2005 01:19AM
4490
June 19, 2005 05:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.