# Problem with last\_insert\_row\_id in sqlite3

**URL:** <https://www.ruby-forum.com/t/problem-with-last-insert-row-id-in-sqlite3/151372>\
**Category:** Ruby\
**Created:** [October 20, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/problem-with-last-insert-row-id-in-sqlite3/151372 "2008-10-20T20:08:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [October 20, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/problem-with-last-insert-row-id-in-sqlite3/151372/1 "2008-10-20T20:08:21Z")

</div>

When I try to use the last\_insert\_row\_id function in sqlite3, I’m  
getting a sqlite syntax error. Since all I’m doing is:

db = SQLite3::Database.new(…)  
id = db.last\_insert\_rowid

I can’t see what could possibly be wrong with something so simple as  
this. Clearly, however, I’m also simple when it comes to this :-), so  
any help would be appreciated.

Thanks,  
Ken

---

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [October 20, 2008, 8:21pm UTC](https://www.ruby-forum.com/t/problem-with-last-insert-row-id-in-sqlite3/151372/2 "2008-10-20T20:21:56Z")

</div>

Problem solved. The error was in incorrect docs on the web. the proper  
function is last\_insert\_row\_id.

Ken
