Home

Cursors should follow a naming convention

Description

    The rule "Cursors should follow a naming convention" states that all cursors used in PL/SQL code should be named in a consistent and logical manner. This helps to ensure that the code is easy to read and understand, and that any changes or additions to the code can be quickly identified. A good naming convention for cursors should include the purpose of the cursor, the type of data it is handling, and any other relevant information. For example, a cursor that is used to retrieve data from a table could be named "cur_table_data".

Key Benefits

  • Consistency and Readability : Cursors should follow a naming convention to ensure that they are easily identifiable and distinguishable from other objects in the database.
  • Efficient Search: Following a naming convention makes it easier to search for cursors, as they can be identified quickly and efficiently.
  • Consistency: Following a naming convention ensures that cursors are consistently named, making it easier to understand and identify them.
  • Organization: Adopting a naming convention helps to organize the database and make it easier to navigate.

 

Non-compliant Code Example

DECLARE
CURSOR deptCursor_ (departmentId_ INTEGER) RETURN departments%ROWTYPE IS  --Non compliant code (Cursor is not following a naming convention)
    SELECT * FROM departments
    WHERE department_id = departmentId_;
BEGIN
  NULL;
END;

Compliant Code Example

DECLARE
CURSOR cur_dept (departmentId INTEGER) RETURN departments%ROWTYPE IS  --Compliant code (Cursor is following a naming convention)
    SELECT * FROM departments
    WHERE department_id = departmentId;
BEGIN
  NULL;
END;
Visual Expert 2024
 VEPLSQLRULE118