+1 vote
by
I have a request and I need to display the request number on the form, how would you solve this problem, at the moment, I get the following id from the database, most likely this is not correct. Maybe you need to use uui field and a new id for each request.

How would you solve it?
by
I have to display the application number on the form
So ask the person you owe how you can get a non-existent requisition number.

2 Answers

+2 votes
by
The application number, as in real life, should be assigned after it is sent.

So maybe it makes sense not to display its number in the form at all. But to assign a number after successful saving and return it to the user.
by
Encoders , you wrote above that you can create an empty request, get its ID, and show it in the form. And when you save the form, you can update the request with this ID with the data received from the form.
But often there will be cases where the form was opened, but did not fill out. And an empty application has already been created. And you will need to periodically clean up such applications.

The second way is not to use auto-incremental IDs. Generate IDs at application level when you display the form. Naturally, in this case, you will have to ensure the uniqueness of such IDs. So that two users who will open this form at the same time won't get the same ID.

But all this is bullshit, not solutions. No one in their right mind does that.
You should not try to solve this problem, but to explain to the customer that his desire - a complete nonsense.

By solving this problem, you'll get yourself a bunch of others. Why complicate it?
by
d-sem I understand that, but is there any way to implement it?
+3 votes
by
Do I understand correctly that you are trying to show an application number that has not yet been created using LAST_INSERT_ID or something like that?
If so, it is strange of course. It is trivial, if two users open the form, they will have the same number of not yet created application.
You can create an "empty" request when opening a form, output its id. And only when the form is sent, fill out this request. Periodically clean up "empty" requests older than a certain time.
But it sounds like nonsense, I do not understand why it is necessary)
by
Ilya , I understand that the iid, after the creation will change
...