Common oracle Stored Procedure skills

Source: Internet
Author: User

Common oracle Stored Procedure skills
1. Stored Procedure structure 1.1 The first Stored Procedure

Create or replace procedure proc1 (p_para1 varchar2, p_para2 out varchar2, p_para3 in out varchar2) as v_name varchar2 (20); begin v_name: = 'zhang Sanfeng '; p_para3: = v_name; dbms_output.put_line ('P _ para3: '| p_para3); end ;/*

 

The above is the simplest stored procedure. A stored procedure is divided into the following parts: create statement: create or replace procedure stored procedure name if there is no or replace statement, it is just a new stored procedure. If the stored procedure exists, an error is returned. Create or replace procedure: if the system does not have this stored procedure, Create a new one. If this stored procedure exists in the system, delete the original one and recreate a stored procedure. Stored Procedure name definition: includes the stored procedure name and parameter list. Parameter Name and parameter type. The parameter names cannot be repeated. The parameter transmission method is IN, OUT, in out in, which indicates the input parameter and value-based transmission. OUT indicates the output parameter, which can be understood as a reference transfer method. It can be used as the output result of the stored procedure for external callers. In out can be used as input parameters or output parameters. You only need to specify the type name for the Data Type of the parameter, and do not need to specify the width. The parameter width is determined by the external caller. The process can have parameters or no Parameter Variable declaration block: followed by the as (is) keyword, can be understood as the declare keyword of pl/SQL, used to declare variables. The variable declaration block is used to declare the variables required for the stored procedure. Its scope is the stored procedure. In addition, the declared variable must specify the width. Complies with PL/SQL variable declaration specifications. Process statement block: The statement block of the process starting with the begin keyword. The specific logic of the stored procedure is implemented here. Exception Handling block: the keyword is exception, which is the exception generated by the processing statement. This part is divided into optional end blocks: results are obtained by the end keyword. */

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.