Comparison Project |
Stored Procedures |
function |
Is there a return value |
There may or may not |
There must be one and only one |
I can perform alone |
can |
Must be executed by execute |
SQL statement (DML or SELECT) Can you call a |
Can not |
And may be located behind the FROM keyword (since the object table return) |
Parameter Type |
Can IN, OUT, IN OUT parameter of the three modes |
Only IN, Oracle can use the IN, OUT, IN OUT three kinds of parameters |
Return Type |
May, IN OUT parameter returns zero or more parameter values OUT |
A single value or a table object |
Storing the difference function and the procedure
1) In general, the process of implementing the functions stored a little more complicated, but a function to achieve specific functions relatively strong. Stored procedures, powerful, can execute a series of database tables include modifying operation; user-defined functions can not be used to perform a set of operations to modify the global database state.
2) For the case of stored procedures can return parameters, such as record set, and the function can return values or table object. Function can return a variable; a plurality of stored procedures can return. Parameters stored procedure can have IN, OUT, INOUT three types, and the function has no return type only when stored ~~ IN class declaration procedure, required to describe a function declaration return type, and the function body must contain a valid RETURN statement.
3) the stored procedure can be used to determine the non-function, the non-allowed determination function built in user-defined functions in the body.
4) stored procedure generally as a separate part is performed (EXECUTE statement execution), and the function can be called (SELECT call) as a part of the query statement, since the function can return a table object, it can query statement in located behind the FROM keyword. SQL statements stored procedures are not available, and can use the function.