PL/SQL Programming   «Prev  Next»

Lesson 7Naming conventions
ObjectiveCreate a naming convention in Oracle.

Creating Oracle Naming Conventions using PL/SQL Variables

Naming conventions, which are often overlooked because they do not seem to be important, do not become an issue until they are not implemented. A lack of naming conventions causes developers to spend their valuable time trying to debug and maintain the application code.

Oracle Naming Conventions

Below are the common naming conventions:
  1. Use a naming convention to avoid ambiguity in the code.
  2. Avoid using the same name for the database column and variables in your code.
  3. Adopt a naming convention for various objects such as the following example: Using v_ as a prefix representing a variable and g_ as a prefix representing a global variable avoids naming conflicts with database objects.
    vg_petname VARCHAR2(30);

Oracle PL/SQL Programming

Naming Conventions

The same naming conventions apply to PL/SQL constants, variables, cursors, cursor variables, exceptions, procedures, functions, and packages. Names can be simple, qualified, remote, or both qualified and remote. For example:
  1. Simple.procedure name only:
    raise_salary(employee_id, amount);
  2. Qualified.procedure name preceded by the name of the package that contains it (this is called dot notation because a dot separates the package name from the
    procedure name): emp_actions.raise_salary(employee_id, amount);	
  3. Remote.procedure name followed by the remote access indicator (@) and a link to the database on which the procedure is stored:
    raise_salary@newyork(employee_id, amount);
  4. Qualified and remote:
    emp_actions.raise_salary@newyork(employee_id, amount)

It is important to create and follow naming conventions.
Standards provide a common language for everyone in the team to understand and maintain the code easily.
The next lesson concludes this module.

Naming Conventions - Exercise

Click the Exercise link below to build a naming convention for your application.
Naming Conventions - Exercise