Re: [sqlite] using auto increment in java
On 11/11/2006 10:16 PM, Will Leshner wrote: You should be able to get the last inserted rowid using the last_insert_rowid() function in a query: SELECT last_insert_rowid(); sorry for the slow reaction, but I had to check my own code first... On Fri, 28 Jul 2006 16:47:21 +0200, Nemanja Corlija <[EMAIL PROTECTED]> wrote: There is also a last_insert_rowid() function that is like an alias for sqlite_last_insert_rowid() API function and it works per db connection. I don't think this this is very useful with true AUTOINCREMENT fields, so sqlite_sequence is really the way to go. based that, I included this in my library... elif engine == 'sqlite': query2 = "SELECT seq FROM sqlite_sequence WHERE name='%s'" % self._table any clarifying comments? thanks a lot, Mario - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] using auto increment in java
On 11/11/06, Patrick Marchwiak <[EMAIL PROTECTED]> wrote: I am working on a Java program that uses SQLite for its database. I am using auto increment on some of my inserts and am wondering if there is some easy way to retrieve the auto incremented rowid right after inserting. I realize that there is a C++ function that does just that , but googling did not turn up much for Java. Thanks. You should be able to get the last inserted rowid using the last_insert_rowid() function in a query: SELECT last_insert_rowid(); - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] using auto increment in java
On 12/11/06, Patrick Marchwiak <[EMAIL PROTECTED]> wrote: I am working on a Java program that uses SQLite for its database. I am using auto increment on some of my inserts and am wondering if there is some easy way to retrieve the auto incremented rowid right after inserting. I realize that there is a C++ function that does just that , but googling did not turn up much for Java. Thanks. Are you using a JDBC driver, if so, which one? I am considering implementing Statement.getGeneratedKeys() using the C API sqlite3_last_insert_rowid() for the driver http://www.zentus.com/sqlitejdbc There may be some issues regarding concurrent connections that will introduce a race condition, but in the simple case it will return properly. d - To unsubscribe, send email to [EMAIL PROTECTED] -