Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

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