What are the Difference between Functions and Procedures ?
- Functions are used for computations where as Procedures can be used for performing business logic
- Functions MUST return a value, Procedures need not be.
- you can have DML(insert, update, delete) statements in a Function. But, you cannot call such a function in a SQL query…
eg: suppose, if u have a function that is updating a table… you can’t call that function in any sql query. - select myFunction(field) from sometable; will throw error.
- function parameters are always IN, no OUT is possible
- function returns 1 value only. procedure can return multiple values(max. 1024)
- we can select the fields from function.in the case of procdure we cannot select the fields.
- Function do not return the images,text whereas stored procedures returns all