Hi,
I have seen plenty of short examples of how to use transactions with postgresql, but none of them (that I have found) are more descriptive than:
BEGIN;
sql query;
ROLLBACK;
//COMMIT;
// uncomment commit if you want to commit it
To me, this doesn't help if I want to check wether or not the whole thing failed. It is my understanding that if something goes wrong it will automatically rollback, even if COMMIT is sent (This is what I've seen personally).
So the question is: How do I check to see if a transaction (e.g. INSERT into TABLE1; INSERT into TABLE2😉 completed successfully so I can perform another function, such as emailing the user of their new subscription. If the transaction fails for some reason, I don't want to email the user, I want to give them a page wich describes the error. Any tutorials or examples is extremely appreciated. Thanks!
-Sean