I have a Play/Slick application where I need to run multiple plain sql queries in a single transaction retrieving result of the last query like so:
val id: Future[Int] = db.run {
sql"""
DECLARE @T TABLE (id INTEGER)
INSERT INTO Foo (name) OUTPUT INSERTED.id INTO @T VALUES ('bar')
SELECT id FROM @T
""".as[Int].head
}
The problem with the above is that it always returns 1
which is a result of the top query that declares a temporary table. How do I get the result of the last query instead? Database in question is MS SQL Server. Play 2.5.4, Slick 3.1.1.
.transactionally
? - insan-e