<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 14, 2014 at 11:43 AM, Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>></span> wrote:<br><div>[...] </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">AFAIK Only sqlite does not (maybe it does today). But that is not a DBMS :-)</blockquote><div><br></div><div>Yes. It would be nice execute the "last_insert_rowid()" to return it in the same cursor (AFAIK, Android SDK use this mechanism in the nativeExecuteForLastInsertedRowId). So it can be same to the MySQL (LAST_INSERT_ID()). =)</div><div><br></div><div>And you can use the TSQLite3Connection.getinsertid method, no? =/</div><div><br></div><div>E.g in a simple raw query in MySQL:</div><div><br></div><div>===============================================================================================</div><div><div>INSERT INTO table_name (col1, col2,...) VALUES ('val1', 'val2'...);</div><div>SELECT LAST_INSERT_ID();</div></div><div><br></div><div><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.8048000335693px;background-image:initial;background-repeat:initial">This will get you back the <code style="margin:0px;padding:1px 5px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:pre-wrap;background:rgb(238,238,238)">PRIMARY KEY</code> value of the last row that <em style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">you</em> inserted:</p><blockquote style="margin:0px 0px 10px;padding:10px 10px 1px;border:0px;font-size:14px;vertical-align:baseline;quotes:none;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.8048000335693px;background:rgb(238,238,238)"><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both;background:transparent">The ID that was generated is maintained in the server on a <em style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">per-connection basis</em>. This means that the value returned by the function to a given client is the first AUTO_INCREMENT value generated for most recent statement affecting an AUTO_INCREMENT column <em style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">by that client</em>.</p></blockquote><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.8048000335693px;background-image:initial;background-repeat:initial">So this is unaffected by other queries that might be running on the server from other users.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.8048000335693px;background-image:initial;background-repeat:initial">S: <a href="http://stackoverflow.com/questions/17112852/get-the-new-record-primary-key-id-from-mysql-insert-query" target="_blank">http://stackoverflow.com/questions/17112852/get-the-new-record-primary-key-id-from-mysql-insert-query</a></p></div></div>===============================================================================================</div><div class="gmail_extra"><br></div><div class="gmail_extra">-- <br><div>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div>
</div></div>