MySQL Forums
Forum List  »  Triggers

Re: Obtain primary key value generated by before-insert trigger
Posted by: Peter Brawley
Date: March 09, 2016 08:49PM

> my calling client must be able to retrieve that value, in a thread-safe manner.

In a Trigger, the value is in new.pkcolname where pkcolname is the name of the pk column. The Trigger could post that value to a semaphore table which the client can read whenever.

> I tried running your select after I performed an insert, but the select always returned null.

Well yes, if it's not auto_increment, that will not work.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Obtain primary key value generated by before-insert trigger
1136
March 09, 2016 08:49PM


Sorry, you can't reply to this topic. It has been closed.

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.