Fix for 'current transaction is aborted'