|
Post by gromiczek on Jun 17, 2022 13:12:11 GMT
Hi - is there a way to batch insert using the class model and get the last rowid before the transaction closes? I know InsertAll() can batch multiple class insertions and also handles opening and closing the transaction, but I'd like to sneak in a rowid request at the end before the transaction closes, just to make sure another transaction hasn't slipped in in the meantime.
I realize that perhaps the best way might be to open my own transaction and execute a sql command batch insert followed by executing a sql request for the rowid, however, my class is rather large and complex and I'd like to avoid potential errors in crafting the sql statement - especially as I update the class model from time to time and rebuild the db.
Thanks again for a great tool - it's been a huge help!
|
|
|
Post by echo17 on Jun 17, 2022 14:17:02 GMT
Thanks for the kind words!
At this time, no there isn't. However, you could run your transaction, then do one more sql statement to get the last row id after the transaction.
If you are having multiple sources connecting to the database, I would recommend having some sort of class that manages all the sql requests. That way you can lock and/or queue up statements so they don't overlap.
|
|
|
Post by gromiczek on Jun 17, 2022 14:41:32 GMT
Gotcha. Yes, I thought to add in one more sql statement afterward and I do have only a single class handling the requests, however, I make the calls async/await to run in the program's background. While I know Sqlite doesn't support async requests, I wondered if I opened and closed a couple transactions in a single function if another async call might slip in and make a transaction in between(??). I'll look into queueing them and see if I can get that to work with the async - async is a bit new to me and I'm still getting my head around the implications.
Thanks!
|
|