![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
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 Thanks !! Floyd _______________________________________________ Informix-list mailing list Informix-list (AT) iiug (DOT) org http://www.iiug.org/mailman/listinfo/informix-list |
#2
| |||
| |||
|
|
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 Thanks !! Floyd _______________________________________________ Informix-list mailing list Informix-list (AT) iiug (DOT) org http://www.iiug.org/mailman/listinfo/informix-list |
![]() |
| Thread Tools | |
| Display Modes | |
| |