SQL Coding Conventions

Names

Package Names

Package names depend on the type of package:

Stand-Alone Packages
Stand-alone packages can be named whatever makes sense. For example, we already have a package named IP.

Main NetDB Package
There is a main NetDB package, named NetDB, containing constants and errors.

NetDB Database-Dependent Packages
Packages that depend on the NetDB database, those that reference NetDB tables for example, must be named using the prefix NetDB_. For example, the package for working with NetDB names is called NetDB_Name.

Function Parameter and Variable Names

Oracle uses barewords for function parameter and variable names, so parameter and variable names can easily conflict with column names. To avoid that problem, we define the following standards and recommendations:

Parameters
Parameter names should always start with the prefix p_ - p_name for example.

Variables
There are no hard and fast rules for variable names, however, we heartily approve of using a v_ prefix for variable names that might conflict with column names - v_netid for example.

View Names

View names must have a 2-character prefix identifying what part of NetDB they're used by. For example, simple search views should be named with a prefix of SS_. So far, the following prefixes have been defined:

    FS_   full search
    SS_   simple search
    SR_   service reports
    MR_   management reports

PL/SQL Functions and Procedures

Errors and Exceptions

Use the raise_application_error() procedure when an error would prevent further processing. Be sure to use a unique error number and register it in the NetDB package.

Recoverable errors should be signaled by returning an appropriate value from the function and an optional status parameter containing an error message.

Keep in mind that error messages will inevitably be presented to the end user and write them for that audience.