Re: Basic question about structuring SQL

2020-07-07 Thread David G. Johnston
On Tue, Jul 7, 2020 at 4:41 AM Robert Inder wrote: > So how should I structure my chunks of SQL so that I can have "safe" > (all-or-nothing) blocks, > AND use them from within one another? > While there are more advanced constructs that may aid here I would suggest just following two rules: top

Re: Basic question about structuring SQL

2020-07-07 Thread Laurenz Albe
On Tue, 2020-07-07 at 12:40 +0100, Robert Inder wrote: > NOW, I want to do the same for a BIGGER task. > BUT I realise that if I create bigger-task.sql like this... >BEGIN; > <> >\i do-something-useful.sql > <> >COMMIT; > ...the COMMIT inside "do-something-useful.sql" closes

Re: Basic question about structuring SQL

2020-07-07 Thread Jason Wang
I don't think nested commit is supported however you might want to put logic in do-something-useful.sql into a stored procedure without commit and your BIGGER task just calls this SP and commits at the end; you can run the SP by itself to have transaction protected. /Jason On Tue, 7 Jul 2020 at 2