That looks like trouble to me. Suppose you get the next available number, do something with it, then somebody else makes an insert in the meantime. You would need to make a pessimistic SQL statement to guard against that which raises the risk of failed transactions.
I think it would be better actually inserting the item using dummy values if you need to, retrieve the id number, then do whatever it is you need to do with it.
I can't imagine actually needing the ID number before making an insert, but my brain is not working that well today.