Home

SELECT statements used as argument of EXISTS statements should be selective

Rule description

  • SELECT statements used as argument of EXISTS statements should be selective

 

Non-compliant Code Example

SELECT 
    NAME,
    ADDRESS,
    CREDIT_LIMIT       
FROM
    CUSTOMERS
WHERE EXISTS (SELECT NAME FROM VENDOR);             --Non compliant code (SELECT statements used as argument of EXISTS statements is not selective)

Compliant Code Example

SELECT 
    NAME,
    ADDRESS,
    CREDIT_LIMIT       
FROM
    CUSTOMERS
WHERE EXISTS (SELECT NAME FROM VENDOR WHERE NAME IS NOT NULL);  --Non compliant code (SELECT statements used as argument of EXISTS statements is selective)
Visual Expert 2020
 VEPLSQLRULE34