dbTalk Databases Forums  

best practice for inserting next token ?

comp.databases.informix comp.databases.informix


Discuss best practice for inserting next token ? in the comp.databases.informix forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Floyd Wellershaus
 
Posts: n/a

Default best practice for inserting next token ? - 06-14-2010 , 09:05 AM






Hi,
We have a table whose primary key ( an integer ) acts like a serial token, but is not a serial datatype.
We have a need to have a piece of code that would randomly insert new rows.
As far as I know, the only way is to select max(token) and then use the next highest integer in the insert statement.
The problem is we need to make sure that nothing sneeks in and grabs that token, between the select max and the insert.
The only think i can think of is to lock the table for update before doing the select in a transaction.
Is there something I'm missing or is there another practice that is used in these scenarios ?

No, I can't change the datatype to what it should be, because that means our developers would have to modify code and they don't do that. >; satire

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.