score:0

Accepted answer

If I understand it correctly this is not possible for now in automatic way. If one is not afraid, this can be done this way. Obtaining the id of last insert (per each master record insertion):

postgreSQL function for last inserted ID

Then using it in SQ:

http://groups.google.com/group/scalaquery/browse_thread/thread/faa7d3e5842da82e

This code shows the MySql way. I'm posting it to the list for posterity's sake.

val scopeIdentity = SimpleFunction.nullaryLong

val inserted = Actions.insert( "cat", "eats", "dog)

//Print out the count of inserted records. println(inserted )

//Print out the primary key for the last inserted record. println(Query(scopeIdentity).first)

//Regards //Bryan

But since for auto incremented fields you have to use projections excluding autoinc fields, and then inserting tuples instead of named record types, there is a question if it is not worth to hold breath until SQ will support this directly.

Note I am SQ newbie, I might just misinform you.


Related Query

More Query from same tag