/sql endpoint transactions
Hi
I was reading this post: https://discord.com/channels/1176467419317940276/1193786856215687238/1194217845056348200
Is there doco available for the /sql API endpoint?
I'm trying to understand how to create a serializable transaction containing a SELECT and an INSERT where the latter depends on the result of the former. Is this possible with the /sql API?
Thanks
Ben
9 Replies
absent-sapphireOP•2y ago
I guess I could do this with a INSERT...INTO...SELECT statement?
continuing-cyan•2y ago
PostgreSQL Documentation
6.4. Returning Data from Modified Rows
6.4. Returning Data from Modified Rows # Sometimes it is useful to obtain data from modified rows while they are being …
continuing-cyan•2y ago
Isnt this he what you need?
Insert into xxxx returning…
absent-sapphireOP•2y ago
Actually my transaction is a select -> insert -> update
I think I need a CTE with RETURNING
continuing-cyan•2y ago
update also supports the returning keyword
do you need something like INSERT INTO ... SELECT FROM
or is the select in order to get some other information for your insert?
absent-sapphireOP•2y ago
Yeah thanks @Flo I think I can see a path forward now.
Is there any update on the /sql API endpoint doco?
Is there any way to control the transaction from the api client?
harsh-harlequin•2y ago
Hey @bensullivan,
Can you share a sample query of what you're aiming at? I'm happy to debug and help.
absent-sapphireOP•2y ago
I ended up going to vanilla JDBC for the transaction - it was too complicated with the API
Thanks for offer of help
harsh-harlequin•2y ago
Alright, do let me know if you need anything!