[Oracle] the difference between a stored Procedure (Procedure) and a (custom) Function

Source: Internet
Author: User

[Oracle] the difference between a stored Procedure (Procedure) and a (custom) Function (Function) the Stored Procedure (custom) Function needs to be executed independently, and there is not necessarily a return value; functions can be called everywhere and must return values, not necessarily variables or tables. It is used to complete specific operations or tasks in the database. When declared in the header of a specific data program, it does not need to be described. When declared in the header of the returned type program, it must return the type. It can be executed as an independent statement and cannot be executed independently, must be called as part of the expression. Zero or multiple values can be returned through the out/in out statement. One value can be returned through the return statement. in the SQL statement, the stored procedure and function execution cannot be called in the SQL statement. the essence is the same: when stored procedures and functions are executed, SQL Manager will go to procedure cache to obtain the corresponding query statement. If no query statement exists in procedure cache, SQL Manager compiles stored procedures and functions. Example: // create or replace procedure add_emailinfo (e_name email_info.fullname % type, e_address %% type) isbegininsert into email_info (fullname, email_address) values (e_name, e_address); end; // call add_emailinfo ('test _ name', 'test _ address') during the call process; // else // create or replace function sel_emailinfo (s_name email_info.fullname % type) return varchar2 isv_address varchar2 (30); beginselect email_address into v_address from email_info where trim (fullname) = trim (s_name); return v_address; end; // call the select sel_emailinfo ('test _ name') from dual;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.