Oracle Pl/sql Programming Specification Guide

Source: Internet
Author: User
Tags naming convention

The case of PL/SQL programming specification

As in SQL, Pl/sql is case-insensitive. Its general guidelines are as follows:

Keywords (BEGIN, EXCEPTION, end, IF THEN else,loop, End LOOP), data type (VARCHAR2, number), internal functions (least, SUBSTR), and user-defined subroutines (procedures, functions,packages), using uppercase.

Variable names, as well as column and table names in SQL, using lowercase.

Second, the PL/SQL programming specification blank

Whitespace (blank lines and spaces) is as important in pl/sql as it is in SQL, because it is an important factor in improving the readability of your code. In other words, you can manifest the logical structure of your program by using indentation in your code. Here are some suggestions:

Leave a space at the left and right of the equals sign or comparison operator;

The structure words (DECLARE, BEGIN, EXCEPTION, end,if and End IF, loop and end loop) are arranged left. In addition, nested structures in the structure are indented three spaces (using the SPACEBAR instead of the TAB key);

The main code segment is separated by a blank line;

Separate the different logical parts of the same structure on separate lines, even if the structure is short. For example, if and then are placed on the same line, and else and end if are placed on separate lines.

III. naming convention for PL/SQL programming specifications

Using the following prefix is helpful for avoiding conflicts with keywords and table names:

V_ variable Name

CON_ constant Name

I_ input parameter name, o_ output parameter name, Io_ input and output parameter name

C_ cursor name or cursor name _cur

RC_ REF cursor Name

R_record name or record name _rec

For R_stud in C_stud LOOP ...

For Stud_rec in Stud_cur loop

Type_ name, name _type (user-defined type)

T_ table name, table name _tab (pl/sql table)

Rec_record name, record name _rec (record variable)

E_ exception Name (user-defined exception)

The name of the package should describe the main functions of stored procedures and functions within the package

The name of the stored procedure should describe the action performed by the stored procedure

The name of the function should describe the returned variable

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.