Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 read consistency issue

Author  Topic 

simflex
Constraint Violating Yak Guru

327 Posts

Posted - 2002-09-07 : 17:14:27
Dear gurus!
I am developing a small project for our company but I ran into an issue that I need your help on.
The company wants to make sure that if any employee is doing an update on a table, that no other employee can update the same table at the same time.
In other words, once an employee is doing an update on a table, the rest of the employees need to be deallocated to allow for read consistency.
What is the best way to address this issue?
Is there a code that will do the trick?
thanks in advance

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2002-09-07 : 21:09:03
Is this being developed using SQL Server or Access?
If SQL Server which version?



Edited by - ehorn on 09/07/2002 21:22:57
Go to Top of Page

simflex
Constraint Violating Yak Guru

327 Posts

Posted - 2002-09-07 : 22:46:07
thank you for your response.
this is being developed with sql server.

Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2002-09-08 : 08:39:49
I believe what you are requesting is to perform a transaction.

A transaction is a sequence of operations performed as a single logical unit of work. A logical unit of work must exhibit four properties, called the ACID (Atomicity, Consistency, Isolation, and Durability) properties, to qualify as a transaction:

Atomicity

A transaction must be an atomic unit of work; either all of its data modifications are performed, or none of them is performed.

Consistency

When completed, a transaction must leave all data in a consistent state. In a relational database, all rules must be applied to the transaction's modifications to maintain all data integrity. All internal data structures, such as B-tree indexes or doubly-linked lists, must be correct at the end of the transaction.

Isolation

Modifications made by concurrent transactions must be isolated from the modifications made by any other concurrent transactions. A transaction either sees data in the state it was in before another concurrent transaction modified it, or it sees the data after the second transaction has completed, but it does not see an intermediate state. This is referred to as serializability because it results in the ability to reload the starting data and replay a series of transactions to end up with the data in the same state it was in after the original transactions were performed.

Durability

After a transaction has completed, its effects are permanently in place in the system. The modifications persist even in the event of a system failure.

Specifying and Enforcing Transactions
SQL programmers are responsible for starting and ending transactions at points that enforce the logical consistency of the data. The programmer must define the sequence of data modifications that leave the data in a consistent state relative to the organization's business rules. The programmer then includes these modification statements in a single transaction so that Microsoft® SQL Server™ can enforce the physical integrity of the transaction.

It is the responsibility of an enterprise database system, such as SQL Server, to provide mechanisms ensuring the physical integrity of each transaction. SQL Server provides:

Locking facilities that preserve transaction isolation.


Logging facilities that ensure transaction durability. Even if the server hardware, operating system, or SQL Server itself fails, SQL Server uses the transaction logs, upon restart, to automatically roll back any uncompleted transactions to the point of the system failure.


Transaction management features that enforce transaction atomicity and consistency. After a transaction has started, it must be successfully completed, or SQL Server undoes all of the data modifications made since the transaction started.

For detailed information you may refer to the SQL Server books online for more information on performing transactions.

Keywords:

Concurrency Problems
Isolation Levels
BEGIN TRANSACTION
COMMIT TRANSACTION
ROLLBACK TRANSACTION
Locking Architecture


There are also many good references on this site relating to transactions.

I hope this helps.



Edited by - ehorn on 09/08/2002 08:49:55
Go to Top of Page
   

- Advertisement -