-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get autoincremented value back after insert #10
Comments
Supporting this feature in ScalaQuery is challenging because different DBMSs require very different solutions (see http://en.wikipedia.org/wiki/Insert_%28SQL%29#Retrieving_the_key for an overview). Some of these solutions can be used easily on top of ScalaQuery (e.g. LAST_INSERT_ID() for MySQL) whereas others would need support from the ScalaQuery drivers (e.g. the RETURNING clause). In these cases, I suggest creating GUIDs on the client side or SELECTing incremented sequence values and using them for subsequent INSERTs as a work-around. I am leaving this ticket open in the hope that it will be possible to define semantics for such a feature that can be made to work on most supported DBMSs. |
I'm using H2 where the function is :
could be error prone for concurrent |
You can wrap add SCOPE_IDENTITY() as a ScalaQuery function:
And then use it in queries:
Concurrent access is not a problem because SCOPE_IDENTITY() works independently for each session. |
I would vote even for partially implementing this, after all other features are also not equally implemented for all databases. If I am not mistaken this feature is essential to fully support "clustered" inserts (master record + slave records). |
JDBC has support for this. See e.g. http://www.xyzws.com/javafaq/how-to-retrieve-automatically-generated-keys-in-jdbc/173. |
Is there a plan when this will be implemented? |
I think in SLICK (unless someone contributes it) -- I don't think Stefan is On Mon, Mar 26, 2012 at 1:47 AM, gsigmund <
|
ok. Is there info about SLICK available on the web? |
Fixed in 09a65a8 |
If I want to insert values to table with autoincremented row, I want it's value back. How can I accomplish this with Scala Query?
The text was updated successfully, but these errors were encountered: