Informix Guide to SQL: Tutorial
Chapter 4: Modifying Data
Home
Contents
Index
Master Index
New Book
Concurrency and Locks
If your database is contained in a single-user workstation, without a network connecting it to other computers, concurrency is unimportant. In all other cases, you must allow for the possibility that, while your program is modifying data, another program is also reading or modifying the same data. C
oncurrency
involves two or more independent uses of the same data at the same time.
A high level of concurrency is crucial to good performance in a multiuser database system. Unless controls exist on the use of data, however, concurrency can lead to a variety of negative effects. Programs could read obsolete data; modifications could be lost even though it seems they were entered successfully.
To prevent errors of this kind, the database server imposes a system of
locks
. A lock is a claim, or reservation, that a program can place on a piece of data. The database server guarantees that, as long as the data is locked, no other program can modify it. When another program requests the data, the database server either makes the program wait or turns it back with an error.
You use a combination of
SQL
statements to control the effect that locks have on your data access:
SET LOCK MODE
and either
SET ISOLATION
or
SET TRANSACTION
. You can understand the details of these statements after reading a discussion on the use of
cursors
from within programs. Cursors are covered in
Chapter 5, "Programming with SQL,"
and
Chapter 6, "Modifying Data Through SQL Programs."
For more information about locking and concurrency, see
Chapter 7, "Programming for a Multiuser Environment."
Informix Guide to SQL: Tutorial
, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.