Procedures and functions of Oracle Database PL/SQL
Source: Internet
Author: User
4) process 1. Basic Concepts: Oracle allows you to create and store compiled PL/SQL statements in the database. Program This type of program includes processes, functions, packages, and triggers. We can save the business logic, business rules, and other written procedures or functions to the database and call them by name for better sharing and use. There are three types of parameters in the process: in/out/In out; 2. create process 1) syntax create [or replace] Procedure <process name> (<parameter 1>, [method 1] <Data Type 1>, <parameter 2>, [method 2] <Data Type 2> ,...) is/aspl/SQL process body; 2) example create or replace procedure count_num (in_sex in teachers. sex % Type) as out_num number; begin if in_sex = 'M' then select count (sex) into out_num from teachers where sex = 'M'; dbms_output.put_line ('number of male teachers: '| out_num); else select count (sex) into out_num from teachers where sex = 'F'; dbms_output.put_line ('number of female teachers:' | out_num); end if; end count_num; 3. execute count_num ('M'); execute count_num ('F'); 4. delete process drop procedure count_num; 5) function 1. the basic concept is used to calculate and return a value. An expression is required for calling. 2. create [or replace] function <Function Name> (<parameter 1>, [method 1] <Data Type 1>, <parameter 2>, [method 2] <Data Type 2> ,...) return <expression> is/aspl/SQL process body; -- a return clause create or replace function count_num (in_sex in teachers. sex % Type) as return number; begin if in_sex = 'M' then select count (sex) into out_num from teachers where sex = 'M'; else select count (sex) into out_num from teachers where sex = 'F'; end if; Return (out_num); End count_num; 3. call the declare m_num number; f_num number; begin m_num: = count_num ('M'); f_num: = count_num ('F'); end; 4. delete the function drop function count_num;
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