Oracle----PROCEDURE

Source: Internet
Author: User

--a preliminary understanding of Oracle--procedure,

--1.1 Create a complete procedure with the following format

Create or replace procedure Procedure_name

Is/as

Begin

Subject

exception

Exception Handling Body

End procedure;

Procedure_name is the process name

Or replace is used to overwrite the process of the same procedure name, if created, without or replace and you create a process name that just exists, will be an error

Parameter type: in

Input parameters, indicating that this parameter value can be entered into the process for use by the procedure, is the default type, cannot be modified.

Parameter type: Out

The output parameter, which indicates that the parameter is assigned in the process, can be provided to the part or environment that the process body thinks of.

Parameter type: in Out

Input and output parameters can either receive the actual parameter values, or can be modified by the program, you can output

For example:

Create or replace procedure Comunt_num

(In_sex in Teaches.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_number);

End If;

End Conut_num;

1.2 Call of the stored procedure:

Execute stored procedure name parameter;

1.3 Deletion of stored procedures:

drop procedure Stored Procedure name

Oracle----PROCEDURE

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.