Subject | Two users adding a record with the same code |
---|---|
Author | Gustavo |
Post date | 2007-07-27T13:08:22Z |
Hello:
I will explain my problem with an example.
Suppose I have a Table of ENTERPRISES with a field CODE (numeric), NAME, ADDRESS, etc. Then I have a table EMPLOYEES with a field ENTERPRCODE, NAME, AGE, ADDRESS, etc. Suppose there are already 100 entreprises in the table ENTERPRISES.
1. User John begins to add a new enterprise. The application propose automatically the CODE 101 and John begins to add (in a grid) the employees. The field ENTERPRCODE of the employees he is adding will have the value 101.
2. Almost at the same time (before John post his new enterprise), the user Peter begins to add a new enterprise. The application propose automatically 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.
3. John posts his enterprise.
4. Peter posts his enterprise. At this moment, the application shows a message saying there is already an enterprise with CODE 101. Then Peter 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.
But...
Supose that after item 3 (John posted his enterprise), for any reason Peter makes a refresh of the grid of employees. Then, as the refresh 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!
This is a simplified explanation, but shows the problem.
I think, it could be a solution if the SELECT done by the refresh could "see" only the records that are uncommited by the transaction in wich Peter is working. So it will not see the records commited by John. The question is: Is there a way to do this?
Any other idea?
I use FireBird 2.0, Delphi 5 and IBX.
Thanks in advance
Gustavo
[Non-text portions of this message have been removed]
I will explain my problem with an example.
Suppose I have a Table of ENTERPRISES with a field CODE (numeric), NAME, ADDRESS, etc. Then I have a table EMPLOYEES with a field ENTERPRCODE, NAME, AGE, ADDRESS, etc. Suppose there are already 100 entreprises in the table ENTERPRISES.
1. User John begins to add a new enterprise. The application propose automatically the CODE 101 and John begins to add (in a grid) the employees. The field ENTERPRCODE of the employees he is adding will have the value 101.
2. Almost at the same time (before John post his new enterprise), the user Peter begins to add a new enterprise. The application propose automatically 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.
3. John posts his enterprise.
4. Peter posts his enterprise. At this moment, the application shows a message saying there is already an enterprise with CODE 101. Then Peter 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.
But...
Supose that after item 3 (John posted his enterprise), for any reason Peter makes a refresh of the grid of employees. Then, as the refresh 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!
This is a simplified explanation, but shows the problem.
I think, it could be a solution if the SELECT done by the refresh could "see" only the records that are uncommited by the transaction in wich Peter is working. So it will not see the records commited by John. The question is: Is there a way to do this?
Any other idea?
I use FireBird 2.0, Delphi 5 and IBX.
Thanks in advance
Gustavo
[Non-text portions of this message have been removed]