mysql - How to restore auto IDs in transaction rollback -


i not sure if behavior of db or application. if transaction fails @ point records had been added table auto-generated ids, id 22, , there's rollback there way re-use id 22? way table restored -- regards next auto id -- before failed transaction.

here code have been running point of failure indicated:

transaction {     grc = ormexecutequery( "from relation1 somid=#form.someid#" );     if( arraylen( grc ) gt 0 )     {         ogr.id = [];         for( =1; lte arraylen(grc); = + 1 )         {             grcnew = entitynew( "relation2" );             grcnew.setfirstname( grc[i].getfirstname() );             .........             entitysave( grcnew );             ormflush();             ogr.id[i] = grcnew.getid();             entitydelete( grc ); //<<--- **point of failure**         }     } } 

how can prevent losing ids in relation2 whenever there's transaction rollback due failure delete corresponding entity/record in relation1? database should change or application?

from mysql.com site, there still gaps. not sure use case gaps shouldn't problem. if need consecutive numbers should either auto-generate them in way (e.g. outside mysql in php or other language). luck.

http://dev.mysql.com/doc/refman/5.0/en/innodb-auto-increment-handling.html


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -