|
 |
|
ss
Oracle Tips by Burleson |
Transactions
A transaction is a logically grouped set of
INSERTs, UPDATEs and DELETEs that should all succeed or fail as a
group. We just found a new author that has already written a book.
We want to enter the data into our PUBS database. Because we
normalized our schema, we have to enter the data into three
different tables; author, book_author and book. We want all three
inserts to either succeed or fail as a group; otherwise, we will
have some data in some tables but not a complete record of the new
author and his book. We log onto the database and insert the three
rows of data.
SQL> INSERT INTO AUTHOR
2 VALUES ('A11l', 'john',
3 'garmany', '123-345-4567',
4 '1234 here st', 'denver',
5 'CO','90204', '9999');
1 row created.
SQL> INSERT INTO BOOK_AUTHOR VALUES ('A111',
'B130', .20);
1 row created.
SQL> INSERT INTO BOOK
2 VALUES ('B130', 'P002', 'easy oracle
sql',
3 'miscellaneous', 9.95, 1000,
15, 0, '',
4 to_date ('02-20-2005','MM-DD-YYYY'));
1 row created.
SQL> commit;
Commit complete.
The above book excerpt is from:
Easy Oracle
SQL
Get Started
Fast writing SQL Reports with SQL*Plus
ISBN 0-9727513-7-8
John Garmany
http://www.rampant-books.com/book_2005_1_easy_sql.htm |