Special

Special Print Closeout!

We're clearing out the remainder of our print issues at fire sale prices -- as much as 75% off! Quantities are extremely limited and only available while supplies last. Hurry to take advantage of this one-time offer.

RBD Magazines

Once these printed back issues are gone, they are gone!

Article Preview


Buy Now

Print:
PDF:

REALSQLDatabase (SQLite)

Triggers and Views

Issue: 5.2 (January/February 2007)
Article Description: No description available.
Article Length (in bytes): 4,212
Starting Page Number: 36
RBD Number: 5213
Resource File(s): None
Related Link(s): None
Known Limitations: None

Excerpt of article text...

For my last column on REALSQLDatabase/SQLite topics, we'll be covering transactions and a couple administration commands.

Transactions

A transaction is simply a group of database statements that will change the database in some way. You create a transaction when you want all these changes to be applied together or to not be applied at all, such as when there is a failure.

A typical example is a bank transfer. A bank transfer involves adding money to one account while removing it from another account. On the surface, that seems rather simple. This is what two SQL statements might look like to do this:

UPDATE account SET amount = amount - 1000 WHERE owner = 'Marc';

UPDATE account SET amount = amount + 1000 WHERE owner = 'Paul';

Now imagine what might happen to the accounts if there was a failure between decrementing Marc's account and incrementing Paul's account. If you were not using a transaction and instead just making the changes permanent after each command, then Marc's account would be out $1000, but no money would have been added to Paul's account. Obviously, that's bad!

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com