I'm using asp.net with postgresql and the odbc postgresql driver.
I have a table for generating unique numbers. To get the next number I SELECT the current number, add 1 and then UPDATE with the new number...
//GET CURRENT NUMBER
DocketNumberTable = DocketNumberAdapter.GetAllDocketNumberData();
DocketNumberRow = DocketNumberTable.Select();
DocketNumber = Convert.ToDecimal(DocketNumberRow["docketno"]);
//UPDATE NUMBER +1
I want to be able to Lock the table between the SELECT query and the UPDATE query as to avoid any other user intercepting the process and causing a conflict.
I know that this is quite unlikely becuase the time it would take to carry out the two transactions is minimal but I thought it would be good practice and worth knowing.