Navigation:  Programming Cookbook > Database Connectivity > Transactions >


Previous pageReturn to chapter overviewNext page

Let's see how a typical updating transaction might work:

c beginRWTxn.

c exec: 'delete from Suppliers where CompanyName=''Object Arts Ltd'''.

c exec: 'delete from Suppliers where CompanyName=''Bernies Burgers Inc'''.

c commitTxn.


The #beginRWTxn message sent to the connection instance started a new read-write transaction (i.e. one that can read from, and modify, the database). You then executed a couple of DELETE statements and finally chose to commit the transaction to the database using #commitTxn. It is not until this point that the records are actually deleted from the underlying data table and you can guarantee that the deletions will occur as an indivisible operation. That is, you can be sure that either both operations will complete or, possibly, both will fail. You may want to check that the records have indeed been removed:

c query: 'select * from Suppliers'. "Inspect it"