0% found this document useful (0 votes)
6 views1 page

SOQL Exceptions

Uploaded by

Kaleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

SOQL Exceptions

Uploaded by

Kaleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SOQL Exceptions Cheat Sheet

1. QueryException

• No rows for assignment: Occurs when a query returns no result


but you assign it to an sObject instead of a list.
Use a list to handle cases with zero results.

• Non-selective query: The query pulls too many records due to


poor filtering (over 200K).
Add indexed fields or more specific filters for better
performance.

2. LimitException

• Too Many SOQL Queries (101): You’ve hit the 100-query limit in
a single transaction.
Bulkify your code by querying outside loops and using Maps
and collections.

3. SObjectException

• Field not queried: You’re trying to access a field that wasn’t


selected in the query.
Always SELECT the fields you need to avoid this.

4. ListException

• List has no rows: You’re trying to access an element from an


empty list.
Always check list.size() or list.isEmpty() before
accessing.

5. Too Many Query Rows

• 50,000+ records returned: Query exceeds the maximum row limit.


Use pagination (LIMIT, OFFSET) or batch processing to stay
within limits.

6. InvalidFieldException

• Misspelled or non-existent field: The field doesn’t exist or


is misspelled in the query.
Double-check field names and maintain a field reference for
accuracy.

Sameer Vishwasrao

You might also like