This example shows how you might specify a transaction:
begin transaction royalty_change /* A user sets out to change the royalty split */ /* for the two authors of The Gourmet Microwave. */ /* Since the database would be inconsistent */ /* between the two updates, they must be grouped */ /* into a transaction. */ update titleauthor set royaltyper = 65 from titleauthor, titles where royaltyper = 75 and titleauthor.title_id = titles.title_id and title = "The Gourmet Microwave" update titleauthor set royaltyper = 35 from titleauthor, titles where royaltyper = 25 and titleauthor.title_id = titles.title_id and title = "The Gourmet Microwave" save transaction percent_changed /* After updating the royaltyper entries for */ /* the two authors, the user inserts the */ /* savepoint "percent_changed," and then checks */ /* to see how a 10 percent increase in the */ /* price would affect the authors’ royalty */ /* earnings. */ update titles set price = price * 1.1 where title = "The Gourmet Microwave" select (price * royalty * total_sales) * royaltyper from titles, titleauthor, roysched where title = "The Gourmet Microwave" and titles.title_id = titleauthor.title_id and titles.title_id = roysched.title_id rollback transaction percent_changed /* The transaction rolls back to the savepoint */ /* with the rollback transaction command. */ /* Without a savepoint, it would roll back to */ /* the begin transaction. */ commit transaction