Procedure vs Function
Difference Between Procedure and Function
Procedure and functions are generic terms used in computer science, interchangeably with method, subroutine, etc. However, in database programming they mean very specific things. So I’m going to assume you want to know, what is the difference between procedure and function in databases.
Both procedures and functions are used in Oracle’s programming language PL/SQL to allow your database to perform functionality when certain events happen in the database. For example, you can have a stored procedure run when data is inserted into a table, or have a function run when you’re calculating payroll.
When you create a function, it has to have a return statement inside it. For example, if you were calculating the area of a circle, you would call the function, pass it the radius of the circle, and the function would return the area of the circle back to whatever called it.
A procedure, on the other hand, doesn’t need to have a return statement. Instead, it can just perform an action. You pass it the parameters, like the radius of the circle, and have the procedure just insert the radius into a table. No data is returned back to whatever called it.
So, just to recap, the main difference between a procedure and function (when you’re doing database programming), is that functions have a return statement, while procedures don’t.
Labels: differences
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home