Hello there... interesting but I m quite sure that implementing an autonumber this way within a trigger and select MAX SOQL is NOT thread safe... so in case you run a batch that creates for instance in parallel multiple transactions (opportunities here) that the parallel threads may query the exact same last MAX number and thus create opportunities with the exact sale NEXT +1 incremented sequence number... in the underlying database, when we use the autonumber feature, i think there must be some provisioning/locking mecanism that forces calling requests to be handled/satisfied 1 by 1 (necessary bottleneck)...
Write an answer...
0/9000