On 4 Apr 2012, at 8:08pm, gwenn <gwenn.k...@gmail.com> wrote:

> * In JDBC API, there is a method to retreive the generated key during an 
> insert:
> http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#getGeneratedKeys()
> * With SQLite API, there is: sqlite3_last_insert_rowid.
> Let suppose that:
> - the primary key is correctly declared to make it an alias for the rowid,
> - and the connection is not shared.
> 1) Do you know how to retreive the column name of the primary key (the
> table name is not known) ?

You can pluck the primary key from the CREATE TABLE command you can find in 
sqlite_master, though you'll have to parse it out from there.

However, note that the primary key may be more than one column:

CREATE TABLE something (column1, column2, column3, PRIMARY KEY (column1, 
column2))

though this shouldn't happen under the constraints you gave above.

> 2) Do you know if there are other bindings that implement/support this
> kind of feature ?

Can't think of any advantage to it.  Unless the programmer defined a column 
called _rowid_ I can always use that, and there's too much likelihood of 
someone else using a compound key as above.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to