create [or replace] PRocedure procedure name (parameter list)
As
Plsql Sub-program body;
After the stored procedure is finished, the stored procedure is called;
There are two ways of doing this:
1.exec stored procedure name ();
2.pl/sql
Begin
Stored procedure name ();
End
/
How to debug and run PL/SQL statements;
Enter Debeg mode
A function is a named stored program, can take parameters, and returns a computed value; A program written with a PL/SQL statement;
Functions and procedures are similar in structure, but must have a return clause for returning function values;
create [or replace] function name (parameter list);
return function value type;
As
Plsql Sub-program body;
In and out parameters;
In general, the difference between a stored procedure and a stored function is that the storage function can have a return value;
And the stored procedure has no return value;
Both procedures and functions can specify one or more output parameters through out, and we can use out parameters to return multiple values in procedure and function implementations;
Both stored procedures and stored functions can have out parameters:
Both stored procedures and stored functions can have multiple out parameters;
The stored procedure can implement the return value through the out parameter;
When to use stored procedures/storage functions;
Principle:
If there is only one return value, use the stored function, otherwise, use the stored procedure;
How stored functions and stored procedures are called in the application;
Oracle stored procedures and custom functions