|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Multi user environment and record ID
Hi,
I'm writing a delphi app connected to Firebird. I need to add in a multi user environment a new record with a random ID (but unique in the DB). So the steps I should follow are: 1) generate the random ID 2) check if the ID exists 3) if not then add the record, else back to 1 I'm concerned about the time between ID checking and record adding. What if in that interval another user adds a record with the same ID. What is the best way to solve it with SQL? How can I "lock" a random ID? Thanks Enrico |
|
#2
|
||||
|
||||
|
First of all you could use a generator for the ID (but that wouldn't be random) ... to solve your problem you need to create an unique INDEX on the ID, so that when the user tries to commit the transaction if the ID already exists, he receives an error.
Good luck, Silver |
|
#3
|
|||
|
|||
|
Quote:
Why do you need (why do you think you need) random IDs ? Can't you just use the standard method to obtain unique IDs, i.e. generators ? |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Multi user environment and record ID |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|