Search Postgresql Archives

Re: Basic question about structuring SQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 7, 2020 at 4:41 AM Robert Inder <robert@xxxxxxxxxxxxxxxxx> 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-level scripts handle transactions - usually just a single BEGIN/COMMIT at the top/bottom of the script respectively.  These are scripts you are allowed to name on the psql command line.
support scripts don't handle transactions - these are scripts you include into the main script with \i or \ir

David J.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux