---
schema_version: "1"
id: 03aaa291a9fcb05bdb610fc7b0bb52828afe8dc4dea38c88c6f27e2c3c0eea8d
title: PerformNullCheckOnSoqlVariables (Retired)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/code-analyzer/salesforce-code-analyzer/guides/v3x/salesforce-graph-engine/performnullcheckonsoqlvariables-rule.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/performnullcheckonsoqlvariables-rule.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: be2c8eaeefd2c6366320e21cc80342ee59a20debe58f0b2cd918c8230c8c84cb
products:
  - Salesforce Code Analyzer
---
# PerformNullCheckOnSoqlVariables (Retired)

PerformNullCheckOnSoqlVariables identifies SOQL queries with variables in WHERE clauses that lack null checks.
SOQL queries with variables on WHERE clauses become expensive when the variable value is unintentionally null. When the variable value is null, an O(1) operation turns into an O(n) operation. The entire table is scanned but returns no results.

## Definition

- Source

  - : `@AuraEnabled`-annotated methods.
    `@InvocableMethod`-annotated methods.
    `@NamespaceAccessible`-annotated methods.
    `@RemoteAction`-annotated methods.
    Any method returning a `PageReference` object.
    `public`-scoped methods on Visualforce Controllers.
    `global`-scoped methods on any class.
    `Messaging.InboundEmailResult handleInboundEmail()` methods on implementations of `Messaging.InboundEmailHandler`.
    Any method targeted during invocation.

- Sink

  - : Any database operation.

- Sanitizer

  - : Null checks (`if (x != null) {`).
    Explicit assignment to non-null (`String x = 'asdf'`).
    Checks for specific non-null values (`if (x == 7) {`).

## Interpreting Results

Match any violation message that you receive with this case to understand more about the violation.

### Common Case

> Null check is missing for variable targetName used in SOQL query.

The mentioned variable is referenced by a SOQL query, and the variable is missing a null check. This behavior is expensive. Instead, explicitly perform a null check on this variable, or assign it to a specific non-null value. For example:

```
public Account[] getAccountsMatchingName(String targetName) {
	return [SELECT Id, Name FROM Account WHERE Name := targetName;
}
```
