function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Frederick BunaoFrederick Bunao 

Is there a way to directly use DML statements to manipulate records? And if not can someone explain why?

I am a new-ish Salesforce admin coming from PLSQL work.

I'm aware of using apex to query records, put in a list, use a for loop to change attributes, then update the records in the list.

In my previous life when we needed to do mass updates, we just do an update where statement. Is this possible in Salesforce? And if not, I'd like to know if there is a technical reason behind it. Purely so I can better understand the infrastructure too. I'm currently the only person in the team who has gotten into Salesforce and I'm trying to be able to communicate why we can't or shouldn't do certain things on the platform the same as we do with our custom database. (like have thousands of lines of database logic for automation)
Best Answer chosen by Frederick Bunao
SwethaSwetha (Salesforce Developers) 
HI Frederick,
There is no way to directly use DML statements to manipulate records in Salesforce. This is because Salesforce uses a multi-tenant architecture, which means that multiple customers share the same physical infrastructure. This architecture allows Salesforce to provide a scalable and affordable platform for its customers, but it also means that there are certain restrictions on what customers can do.

To perform mass updates in Salesforce, you should use programmatic approaches like Apex (similar to PL/SQL) or declarative tools like Flows. These tools are designed to work within the Salesforce platform's architecture, allowing you to update records in a controlled and efficient manner while respecting the platform's security and governance measures.

- You can perform bulk updates using Salesforce's Bulk API(dataloader), which is designed to handle large volumes of data. 
- You can use batch apex which allows you to batch process DML statements. This means that you can group multiple DML statements together and execute them as a single operation. This can significantly improve the performance of mass updates.
- Asynchronous programming allows you to perform DML operations in the background.

Related:

https://salesforce.stackexchange.com/questions/45011/how-do-i-mass-update-my-object

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_insert_update.htm

https://help.salesforce.com/s/articleView?id=sf.performing_mass_updates.htm&type=5

If this information helps, please mark the answer as best. Thank you

All Answers

SwethaSwetha (Salesforce Developers) 
HI Frederick,
There is no way to directly use DML statements to manipulate records in Salesforce. This is because Salesforce uses a multi-tenant architecture, which means that multiple customers share the same physical infrastructure. This architecture allows Salesforce to provide a scalable and affordable platform for its customers, but it also means that there are certain restrictions on what customers can do.

To perform mass updates in Salesforce, you should use programmatic approaches like Apex (similar to PL/SQL) or declarative tools like Flows. These tools are designed to work within the Salesforce platform's architecture, allowing you to update records in a controlled and efficient manner while respecting the platform's security and governance measures.

- You can perform bulk updates using Salesforce's Bulk API(dataloader), which is designed to handle large volumes of data. 
- You can use batch apex which allows you to batch process DML statements. This means that you can group multiple DML statements together and execute them as a single operation. This can significantly improve the performance of mass updates.
- Asynchronous programming allows you to perform DML operations in the background.

Related:

https://salesforce.stackexchange.com/questions/45011/how-do-i-mass-update-my-object

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_insert_update.htm

https://help.salesforce.com/s/articleView?id=sf.performing_mass_updates.htm&type=5

If this information helps, please mark the answer as best. Thank you
This was selected as the best answer
Frederick BunaoFrederick Bunao
Perfect. Thank you so much for the explanation. Exactly what I needed.