Home

Individual WHERE clause conditions should not be unconditionally true or false

Rule description

  • Individual WHERE clause conditions should not be unconditionally true or false

 

Non-compliant Code Example

Create TABLE EMPLOYEE
(
  EMP_ID number(10) NOT NULL,
  FIRSTNAME NVARCHAR2(75) NOT NULL,
  LASTNAME NVARCHAR2(75),
  DEPT_ID int,  
  ADDRESS NOT NULL,
  CONSTRAINT pk_employee PRIMARY KEY (EMP_ID)
);

BEGIN
	SELECT
		*
	FROM
		EMPLOYEE
	WHERE
		FIRSTNAME IS NOT NULL;      --Non compliant code (Where clause is unconditionally true as column definition contains not null column)
END;

Compliant Code Example

Create TABLE EMPLOYEE 
(
  EMP_ID number(10) NOT NULL,
  FIRSTNAME NVARCHAR2(75) NOT NULL,
  LASTNAME NVARCHAR2(75),
  DEPT_ID int,  
  ADDRESS NOT NULL,
  CONSTRAINT pk_employee PRIMARY KEY (EMP_ID)
);

BEGIN
	SELECT
		*
	FROM
		EMPLOYEE;               --Compliant code (Where clause is removed)
END;
Visual Expert 2020
 VEPLSQLRULE26