Syncpoint, Commit and Rollback are used together.
- Syncpoint takes a copy of all the resources
- After Syncpoint, updates to the resources are made permanent after Commit.
- After Syncpoint, if updates to resources have to be backed out, then a Rollback is performed.
Take an example where the amount for your loan is deducted directly from your personal bank account.
There are two parts to this operation
1. Deduct amount from your personal account - This would require updating your personal bank account file.
2. Add the amount to your loan account - This would required updating your loan account file.
If after performing step 1, i.e. deducting amount from your personal bank account, the task is unable to perform the update of your loan account file, say because the file was closed to CICS. At this point if you just abend the transaction, the money from your personal bank account is gone, but it has not be added to your loan account.
To prevent such a thing, you would like to identify a single unit of work (UoW) within your transaction. The unit of work in this case would be deducting from one a/c and adding to the other.
At the beginning and end of each unit of work, you would do a syncpoint and a commit which would marking the beginning and end of each UoW. During the processing of a UoW, if something wrong happens, then you would issue a ROLLBACK saying none of the updates that have taken place in this UoW have to happen because something has gone wrong. If everything goes fine, then you would COMMIT the changes.
Now, for CICS to identify the beginning of each UoW, you would issue a SYNCPOINT at which point it would take a backup of all resources to which it can rollback in the event a ROLLBACK command has been issued.
Now the above example is a very simple one. But in much more complex operations you would have mutiple resources, not just files and tables where updates happen constantly. Having SYNCPOINTS during such situations would be more helpful.
In CICS Transactions, CICS, not DB2, is the Transaction Manager
If you issue a EXEC CICS SYNCPOINT, DB2 gets committed as well.
If you issue a EXEC SQL COMMIT, only DB2 stuff gets committed. Other resources - files, TSQs etc remain 'uncommitted'.