Rechercher dans le manuel MySQL
24.2.4 Stored Procedures, Functions, Triggers, and LAST_INSERT_ID()
Within the body of a stored routine (procedure or function) or a
trigger, the value of
LAST_INSERT_ID()
changes the same
way as for statements executed outside the body of these kinds of
objects (see Section 12.15, “Information Functions”). The effect
of a stored routine or trigger upon the value of
LAST_INSERT_ID()
that is seen by
following statements depends on the kind of routine:
If a stored procedure executes statements that change the value of
LAST_INSERT_ID()
, the changed value is seen by statements that follow the procedure call.For stored functions and triggers that change the value, the value is restored when the function or trigger ends, so following statements do not see a changed value.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-stored-routines-last-insert-id.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.