MySQL Forums
Forum List  »  Triggers

Re: LAST_INSERT_ID ia a AFRTER INSERT trigger
Posted by: Hans Verdel
Date: October 04, 2018 02:19AM

Thanks Peter.

I had already tested this. I would like to know at what point last_insert_id() does return a value. The trigger body apparently isn't.


I did some more testing. The proper way is to use NEW.id.
It returns the correct value, whether inserted as a NULL, 0 (zero) or an INT value.
It returns the correct value when left out of the INSERT statement.
It returns the correct value for each seperate row when inserting multiple rows through an INSERT ... SELECT ... statement.


Hope this helps others.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: LAST_INSERT_ID ia a AFRTER INSERT trigger
52
October 04, 2018 02:19AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.