Are PostgreSQL functions transactional?

PostgreSQL 12 update: there is limited support for top-level PROCEDUREs that can do transaction control. You still cannot manage transactions in regular SQL-callable functions, so the below remains true except when using the new top-level procedures. Functions are part of the transaction they’re called from. Their effects are rolled back if the transaction rolls back. … Read more

C# – System.Transactions.TransactionScope

TransactionScope is not only for the databases. Every component that implements IEnlistmentNotification interface can participate in two-phase commit of the transaction scope. Here is an example of transactional in-memory storage: http://www.codeproject.com/KB/dotnet/Transactional_Repository.aspx Also, I’m not sure if there are components in .NET for transactional file IO, but it is pretty easy to implement such component – … Read more

PHP prepared statements and transactions in a loop [duplicate]

Your loop can be optimized by pulling the prepare and bind_param statements out of the loop. $value = null; $mysqli->autocommit(FALSE); $sql = “INSERT INTO temp (`fund_id`) VALUES (?)”; $stmt = $mysqli->prepare($sql); $stmt->bind_param(‘i’, $value); foreach ($pdata as $value) { $stmt->execute(); } $mysqli->commit(); You have turned off autocommit with your autocommit(FALSE) line and therefore don’t need to … Read more

EJB 3.0 – Nested Transaction != Requires New?

RequiresNew does not create a nested transaction because the first transaction is suspended while the second transaction is running. A nested transaction looks like this: Nested transaction example > method1 – begin tran1 > method2 – begin tran2 workA < method2 – commit tran2 < method1 – rollback tran1 (tran2 also rolled back because it’s … Read more