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

Difference between save to database and commit to database

Hi ,


Could someone please point out the difference between 'save to database' and 'Commit to database'? This will be really helpful.





I think the difference is when it first saves it to the database, it is not committed yet and it does the after triggers and workflows and things and if any of those fails, it rollsback the data saved. When it is committed to the database, it is saved completely.


When it is 'saved' to the database, it is still in process of being put into the database.  If there is an error or something at this point, you will not be able to find it in the database afterwards  When it is commited, it is fully in the database.  Any errors once the commit has taken place will not remove the data from the database.


Sry for my ignorance...but what is the use of saving to the Database???

It can commit directly at the end itself only right, why is this intermediate step of saving to Database?




I would assume its so that triggers can execute off of it and do additional validation to stop the final commit if necessary.

Hello Everyone,

Save to database is used to temporarily save a transaction so that you can rollback to that point whenever necessary, in short temporary storage from where we can rollback if something seems not fine. Also on Save to database, a record id is generted. And the changes are limited only to the transaction but you can anytime rollback.

Commit; Commit is used to permanently save any transaaction into database and once strored, everyone knows, that can not be rolled back.
On the other hand, Commit is final stage for a transaciton, where it saves data into database which were there in temporary transactions. Transaction's picture gets over at this place.

*Transaction: A transaction is the process of one or more or series of changes to the database.
Read 6th and 7th point in this link:

!~~Mark as a best answer if you feel so and for encouraging~~!