Ids created out of sequence
Question

I have a problem that I can't find or understand the cause of. In an application I have offers to be created sequentially with the "id" Attribute as Auto Number. It turns out that it was verified that it created everything correctly until Id=21 and from one moment to the next the next Id created was 10020.


Has anyone gone through a similar situation?

BR,

João Roque

mvp_badge
MVP

Hi João Roque,


This happens a few times because when an id is taken, then the auto number increases, even if the id ends up not used because of a rollback.

For instance, you inserted 21 records and you got he records until the id 21. You upload an excel file that creates records up to 10019 but then you have an exception that ends up roll backing the records inserted with ids 22 - 10019. When you insert the next record, it will take the id 10020 and the table ends up like the one in your example.


This is probably what happened. You can also go to the database and set the auto number to 10020 but it's unlikely that somebody does it, and working on the OutSystems cloud, one doesn't even have the access to do that.


Kind Regards,
João

Hi João,

Thanks you for your answer,


but in this case no excel file was loaded or offers created in any other way. The only way to create offers in this application is in a "create offer" button and only one offer is created at a time. It is not possible in this case that users have created around 10000 offers. This situation only happened in one of the environments where the application is. In the other 2 environments, something similar never happened.

BR,

João Roque

mvp_badge
MVP

Hi João,


The excel file was just an example. It could be inserting via SQL, a bulk insert query that was rollbacked, I don't know. From my experience, rollback is usually the explanation for this behaviour, granted that nobody went to the database and set the auto number to a higher number, of course.

Usually, each environment has a different database so it's perfectly normal you have found this in one single environment but not on the others.


Kind Regards,
João

Hi João,

It's a little strange, since we're talking about a test environment only. Nothing is developed in this environment. It only serves as a test for Key end users. :(

BR,

João Roque

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.