sql icon indicating copy to clipboard operation
sql copied to clipboard

Insert returning values?

Open jackfirth opened this issue 8 years ago • 1 comments

I'd like to create a row in a table with an auto-incrementing primary key, retrieve the generated key, and read the value later. Some SQL variants allow specifying that an INSERT statement should return values, e.g. Postgres has the INSERT ... RETURNING clause, Sqlite has the last_insert_rowid() function, SQL Server has INSERT ... OUTPUT, etc. Would a #:returning keyword listing column names make sense for the insert syntax?

jackfirth avatar Jul 15 '17 20:07 jackfirth

I would like to support (some) extensions like PostgreSQL's RETURNING clause, but I haven't decided how to do that yet. And I don't want to try to unify extentions that are too different. For example, it seems like it might be reasonable to unify PostgreSQL's RETURNING and SQL Server's OUTPUT, but it would not make sense to try to unify those with Sqlite's last_insert_rowid().

rmculpepper avatar Jul 16 '17 19:07 rmculpepper