Manas Marthi
02/02/2024, 9:47 PMsuspend fun insertIntoTwoTables(x: Int, y: Int) {
Database.dbQuery{
transaction{
var a = Numbers.insert { it[Numbers.num] = x }
val aId = a.resultedValues?.get(Numbers.id) ?.let { it.toLong() }
val b = Strings.insert {
it[Strings.str] = y.toString()
it[Strings.numId] = aId
}
val bId = b.resultedValues?.get(Strings.id) ?.let { it.toLong() }
return Pair(aId, bId)
}
}
}
AdamW
02/03/2024, 11:03 AMUnit
so this couldn’t work anyway.
No need to open another transaction inside your dbQuery
either.
fun thing(): Int = transaction {
10
} // ok
fun thing() {
transaction {
return 10
}
} // error
fun thing(): Int {
transaction {
10
} // error
}
fun thing(): Int {
return transaction {
10
}
} // ok
Manas Marthi
02/05/2024, 6:00 AMnewSuspendedTransaction
call is taking care of opening the transaction. Isn't it? Is it possible to call a stored procedure using Exposed?AdamW
02/06/2024, 5:07 PMexec
to run arbitrary SQL 👍 And yes, it opens a transactionManas Marthi
02/06/2024, 6:04 PM