Subject | Re: [firebird-support] Two users adding a record with the same code |
---|---|
Author | Martijn Tonies |
Post date | 2007-07-27T13:27:17Z |
Gustavo,
AGE, ADDRESS, etc. Suppose there are already 100 entreprises in the table
ENTERPRISES.
The field ENTERPRCODE of the employees he is adding will have the value 101.
the CODE 101 (the same as the one that is using John) and Peter begins to
add (in a grid) the employees. The field ENTERPRCODE of the employees he is
adding will have the value 101.
change the CODE to 102 and the application automatically changes the field
ENTERPRCODE in the employees. Peter posts again his enterprise and
everithing is OK.
executes a SELECT * FROM EMPLOYEES WHERE ENTERPRCODE = "101", he will now
see the employees that he (Peter) added and the ones that John added to his
other enterprise that is already posted. This is wrong!
is working. So it will not see the records commited by John. The question
is: Is there a way to do this?
a "read consistency" isolation, that way, he would only see HIS 101
employees, which have to be changed to 102 anyway and not see Johns
(committed) 101 employees.
Now, if I only could remember the exact Firebird wording for this
transaction.
What is it, snapshot?
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
> I will explain my problem with an example.ADDRESS, etc. Then I have a table EMPLOYEES with a field ENTERPRCODE, NAME,
>
> Suppose I have a Table of ENTERPRISES with a field CODE (numeric), NAME,
AGE, ADDRESS, etc. Suppose there are already 100 entreprises in the table
ENTERPRISES.
>automatically the CODE 101 and John begins to add (in a grid) the employees.
> 1. User John begins to add a new enterprise. The application propose
The field ENTERPRCODE of the employees he is adding will have the value 101.
>Peter begins to add a new enterprise. The application propose automatically
> 2. Almost at the same time (before John post his new enterprise), the user
the CODE 101 (the same as the one that is using John) and Peter begins to
add (in a grid) the employees. The field ENTERPRCODE of the employees he is
adding will have the value 101.
>message saying there is already an enterprise with CODE 101. Then Peter
> 3. John posts his enterprise.
>
> 4. Peter posts his enterprise. At this moment, the application shows a
change the CODE to 102 and the application automatically changes the field
ENTERPRCODE in the employees. Peter posts again his enterprise and
everithing is OK.
>Peter makes a refresh of the grid of employees. Then, as the refresh
> But...
>
> Supose that after item 3 (John posted his enterprise), for any reason
executes a SELECT * FROM EMPLOYEES WHERE ENTERPRCODE = "101", he will now
see the employees that he (Peter) added and the ones that John added to his
other enterprise that is already posted. This is wrong!
>"see" only the records that are uncommited by the transaction in wich Peter
> This is a simplified explanation, but shows the problem.
>
> I think, it could be a solution if the SELECT done by the refresh could
is working. So it will not see the records commited by John. The question
is: Is there a way to do this?
>Peter should use a transaction that doesn't do "read committed", but have
a "read consistency" isolation, that way, he would only see HIS 101
employees, which have to be changed to 102 anyway and not see Johns
(committed) 101 employees.
Now, if I only could remember the exact Firebird wording for this
transaction.
What is it, snapshot?
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com