You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Bob Hanson <mn...@gmail.com> on 2006/11/21 19:48:37 UTC

insert using a stored procedure

What is the correct method to retrieve the Identity value of a newly
inserted row when using a stored procedure that performs an insert?

Thanks,
Bob

RE: insert using a stored procedure

Posted by Dorin Manoli <Do...@dataireland.ie>.
It depend what database engine you use. Code below is for MySQL

Use this code in xml map file under <insert> node and after insert query

<selectKey .... . . . >

                        select LAST_INSERT_ID() as value          

                  </selectKey>

 

________________________________

From: Bob Hanson [mailto:mnbob70@gmail.com] 
Sent: Tuesday, November 21, 2006 6:49 PM
To: user-cs@ibatis.apache.org
Subject: insert using a stored procedure

 

What is the correct method to retrieve the Identity value of a newly
inserted row when using a stored procedure that performs an insert?

Thanks,
Bob