How can I determine if a transaction is active? I'd like to be able to execute SQL that creates a savepoint regardless of whether or not a transaction is currently active (i.e. if it isn't active, I want to "BEGIN")
You can do
begin;
savepoint foo;
The "begin;" will be a no-op if there is a transaction already.
Also see: https://stackoverflow.com/a/28802471/435563
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With