From: Warren Young Date: August 18 2008 12:59am Subject: Re: insert_id always 0 when using stored procedures List-Archive: http://lists.mysql.com/plusplus/7888 Message-Id: <7174A006-44D4-40A4-9922-DB949FD223F1@etr-usa.com> MIME-Version: 1.0 (Apple Message framework v928.1) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On Aug 15, 2008, at 1:03 PM, Guru Clint wrote: > m_uliLastID = sqlQuery.insert_id() If you look at the MySQL++ code, you'll see that Query::insert_id() maps pretty much directly to the C API function mysql_insert_id(). The documentation for that says: > mysql_insert_id() returns 0 following a CALL statement for a stored > procedure that generates an AUTO_INCREMENT value because in this > case mysql_insert_id() applies to CALL and not the statement within > the procedure. Within the procedure, you can use LAST_INSERT_ID() at > the SQL level to obtain the AUTO_INCREMENT value.