How to avoid salesforce Soql governor limits
Salesforce enforces governor limits on SOQL DML operation, so its very important for developers to keep in to consideration before doing any DML operation




You can do following steps to avoid Soql limit issue
- Avoid using Soql statement inside a loop.
For instance avoid using code similar to one shown below
If you want to query an object then its better to store that in a collection and use that collection inside the loop something like this
We have used Contact map to store the contact data in the collection where accountid is used as key
- Avoid using DML statements inside loops.
For instance below code will trigger Soql limit error
To avoid Soql limit error you need to use collection and do a collection insert
As shown below
Comments
Post a Comment