マルチユーザーアプリケーションのドキュメント番号用に、テーブルの行のIDを予約する必要があります。私を助けてください。
2 に答える
Simplest thing is to do locking 'manualy'. You can add timestamp (the idea is from ORACLE row_scn) and reserve it for some time you think you need it for adding doc number. Basicly, add timestamp column, and alow updates only if (Timestamp coulmn - GETDATE())> time needed
If you absolutely need to reserve a document number, before you have complete data for a document, consider creating a row with the minimal amount of data, then later on you can update the record with valid data.
You may need to add some sort of flags so that you are not using this invalid data for reporting or other purposes. This is very important if others are querying your table.
Another option would be to create a table with an identity field and just enough information to understand the origin of the document. You use this table only for creating the document id and just not use identity feature on your main table. Depending on how far down the development cycle you are this may require major re-design of your code/application.
There are multiple ways you could implement this, however the question is, do you really need to reserve the id, or are you going to the database and causing round trips for no specific reason?