The difference between oracle procedures and functions: 1. Oracle procedures have zero or more parameters and no return value, while Oracle functions can have no parameters or multiple parameters and a return value; 2. Oracle procedures It is called as an independent execution statement, while the oracle function is called as a legal expression.
The operating environment of this tutorial: Windows 10 system, Oracle version 12c, Dell G3 computer.
1. Oracle procedures and functions are stored in the database in compiled form.
Functions can have no parameters or many. parameters and a return value.
Procedures have zero or more parameters and no return value.
2. Both functions and procedures can receive or return zero or more values through the parameter list. The main difference between functions and procedures is not the return value, but the way they are called.
Oracle procedures are called as an independent execution statement:
pay_involume(invoice_nbr,30,due_date);
The function is called as a legal expression:
order_volumn:=open_orders(SYSDATE,30);
The syntax for creating a procedure is as follows:
The syntax of each parameter is as follows
paramter_name mode datatype [(:=|DEFAULT) value]
Extended knowledge:
mode has three forms: IN, OUT, INOUT.
IN means that when the process is called, the values of the actual parameters are passed to the process. The formal parameters are considered read-only. When the process ends, the control will return to the control environment, and the values of the actual parameters are not will change.
OUT When calling a procedure, the values of the actual parameters will be ignored. Within the procedure, formal parameters can only be assigned values, but data cannot be read from them. The contents of the formal parameters will be assigned after the procedure ends. actual parameters.
INOUT mode is a combination of IN and OUT; within the Oracle process, the value of the actual parameter will be passed to the formal parameter. The value of the status parameter can be read or written. After the process ends, the value of the status parameter will Assign actual parameters.
Recommended tutorial: "Oracle Video Tutorial"
The above is the detailed content of What is the difference between oracle procedures and functions. For more information, please follow other related articles on the PHP Chinese website!