Author: Paul King <[hidden email]>
Authored: Sat Apr 18 21:41:10 2015 +1000
Committer: Paul King <[hidden email]>
Committed: Sat Apr 18 21:50:17 2015 +1000
+The easiest way to perform database operations within a transaction is to include the database operation within a `withTransaction` closure as shown in the following example:
+.A successful transaction
+Here the database starts empty and has two rows after successful completion of the operation. Outside the scope of the
+transaction, the database is never seen as having just one row.
+If something goes wrong, any earlier operations within the `withTransaction` block are rolled back.
+We can see that in operation in the following example where we use database metadata (more details coming up shortly) to find the
+maximum allowable size of the `firstname` column and then attempt to enter a firstname one larger than that maximum value as shown here:
+.A failed transaction will cause a rollback
+Even though the first sql execute succeeds initially, it will be rolled back and the number of rows will remain the same.