PL/SQL Code Naming Conventions and Formatting GuidelinesCasePL/SQL, like SQL, is case insensitive. The general guidelines here are as follows :
White SpaceWhite space (extra lines and spaces) is as important in PL/SQL as it is in SQL. It is a main factor in providing readability. In other words, you can reveal the logical structure of the program by using indentation in your code. Here are some suggestions:
Naming ConventionsTo ensure against conflicts with keywords and column/table names, it is helpful to use the following prefixes:
The name of a package should be the name of the larger context of the actions performed by the procedures and functions contained within the package. The name of a procedure should be the action description that is performed by the procedure. The name of a function should be the description of the return variable. FOR EXAMPLE PACKAGE student_admin -- admin suffix may be used for administration. PROCEDURE remove_student (i_student_id IN student.studid%TYPE); FUNCTION student_enroll_count (i_student_id student.studid%TYPE) RETURN INTEGER; CommentsComments in PL/SQL are as important as in SQL. They should explain the main sections of the program and any major nontrivial logic steps. Use single-line comments "--" instead of the multiline "/*" comments. While PL/SQL treats these comments in the same way, it will be easier for you to debug the code once it is completed because you cannot embed multiline comments within multiline comments. In other words, you are able to comment out portions of code that contain single-line comments, and you are unable to comment out portions of code that contain multiline comments. |