Home  >  Article  >  Database  >  What is the difference between oracle procedures and functions

What is the difference between oracle procedures and functions

WBOY
WBOYOriginal
2022-05-31 15:28:413948browse

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.

What is the difference between oracle procedures and functions

The operating environment of this tutorial: Windows 10 system, Oracle version 12c, Dell G3 computer.

What is the difference between Oracle procedures and functions?

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:

What is the difference between oracle procedures and functions

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn