If I use the LOCK TABLE statement via the ODBC interface, it just does not seem to work when multiple users are updating the same table. The scenario is something like this:
1. User 1 retrieves the last record in a table and reads a number
2. User 1 adds 1 to the number and adds a new record to the table.
If between steps 1 and 2, another user performs the same operation it will result in two records having the same number in the field, which for my purposes, is an error.
How do I prevent this from happening? If user 1 executes "LOCK TABLE tablename IN EXCLUSIVE MODE;", user 2 is not prevented from reading the same table. I want to restrict this from happening.
Please remember that I am using VC and ODBC as my programming interface and not PL/SQL. What should I do?