Home

Uninitialized NOT NULL Variables

Rule description

  • NOT NULL variables should be initialized

 

Non-compliant Code Example

DECLARE 
    firstname CUSTOMERS.FIRSTNAME % TYPE NOT NULL;
    lastname CUSTOMERS.LASTNAME % TYPE;
    landmark CUSTOMERS.LANDMARK % TYPE NOT NULL;            --Non compliant code(NOT NULL variables is not initialized)

BEGIN
    SELECT FIRSTNAME, LASTNAME, LANDMARK
    INTO firstname, lastname
    FROM CUSTOMERS

    WHERE(CREDIT_LIMIT = 1800 AND CREDIT_LIMIT > 1100);
            END; 

Compliant Code Example

DECLARE 
    firstname CUSTOMERS.FIRSTNAME % TYPE NOT NULL;
    lastname CUSTOMERS.LASTNAME % TYPE;
    landmark CUSTOMERS.LANDMARK % TYPE NOT NULL;            --Compliant code(NOT NULL variables is initialized)

BEGIN
    SELECT FIRSTNAME, LASTNAME, LANDMARK
    INTO firstname, lastname, landmark
    FROM CUSTOMERS

    WHERE(CREDIT_LIMIT = 1800 AND CREDIT_LIMIT > 1100);
            END; 
Visual Expert 2020
 VEPLSQLRULE7