transactions

Proper way to use a transaction around multiple inserts or updates

烈酒焚心 提交于 2019-12-18 10:57:08
问题 What is the proper way to test for insert/update failures and rollback this transaction if there are any? I don't think what I have will work since my inserts/updates are 3 separate statements and the @@ROWCOUNT will only reflect the last statement executed. BEGIN TRANSACTION Script; GO INSERT INTO TableA (id) VALUES (1) INSERT INTO TableB (id) VALUES (1) UPDATE TableC SET id=1 WHERE id=2 GO IF (@@ROWCOUNT=3 AND @@ERROR=0) BEGIN COMMIT END ELSE BEGIN PRINT 'Error: Rolling back transaction'

PHP / MySQL - how to prevent two requests *Update

无人久伴 提交于 2019-12-18 10:34:29
问题 I have some question ... example: a user will buy something for his USD Check his USD Balance Deduct the USD from his account Make an Order -> order queue user gets his item and the other one gets his USD Lets say, the users makes 5 requests in the same second (very fast). So it is possible (and happen) that 5 requests are running. He has only money to buy only from 1 request. Now the requests are so fast, that the script checks his balance, but is not so fast, that it deduct the money from

Transactions best practices [closed]

你说的曾经没有我的故事 提交于 2019-12-18 10:09:28
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . How much do you rely on database transactions? Do you prefer small or large transaction scopes ? Do you prefer client side transaction handling (e.g. TransactionScope in .NET) over server side transactions or vice-versa? What about nested transactions? Do you have some tips&tricks

is there a difference between a select statement inside a transaction and one that is outside of it

谁说胖子不能爱 提交于 2019-12-18 10:06:02
问题 Does the default READ COMMITTED isolation level somehow makes the select statement act different inside of a transaction than one that is not in a transaction? I am using MSSQL. 回答1: Yes, the one inside the transaction can see changes made by other previous Insert/Update/delete statements in that transaction; a Select statement outside the transaction cannot. If all you are asking about is what the Isolation Level does, then understand that all Select statements (hey, all statements of any

Threaded Django task doesn't automatically handle transactions or db connections?

喜欢而已 提交于 2019-12-18 09:54:38
问题 I've got Django set up to run some recurring tasks in their own threads, and I noticed that they were always leaving behind unfinished database connection processes (pgsql "Idle In Transaction"). I looked through the Postgres logs and found that the transactions weren't being completed (no ROLLBACK). I tried using the various transaction decorators on my functions, no luck. I switched to manual transaction management and did the rollback manually, that worked, but still left the processes as

Is NOLOCK the default for SELECT statements in SQL Server 2005?

。_饼干妹妹 提交于 2019-12-18 09:23:56
问题 I have only SQL Server 2008R2 installed though I need to communicate with customers having 2005. [1] tells: " NOLOCK This does not lock any object. This is the default for SELECT operations. It does not apply to INSERT, UPDATE, and DELETE statements" [2] doesn't seem to mention it, but my checking in SSMS/SS 2008R2 shows that nolock is not default hint for SELECT. Is WITH(NOLOCK) really default in SQL Server 2005 SELECT? Where is it written in BOL2005/2008? Update: Under "Where is it written"

How to get transactions to a @PostConstruct CDI bean method

℡╲_俬逩灬. 提交于 2019-12-18 09:03:37
问题 I'm experimenting with Java EE 7, CDI, JPA and JSF. When the webapp starts, I would like to run an initialization method in my CDI bean (marked with @PostConstruct) that does some work with the database (inserts some rows etc..). For this I need a transaction, but this wasn't as easy as I expected. I have tried adding @Transactional annotation to my method, but apparently it only works with EJB. I actually tried converting my bean to EJB instead of CDI bean, but I still didn't get transaction

Spring @Transactional is not working

十年热恋 提交于 2019-12-18 08:48:22
问题 I am trying to use annotated TX Spring support. Application context XML: <?xml ...> <tx:annotation-driven/> <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource"> ... </bean> <bean id="repository" class="Repository"> <constructor-arg ref="dataSource"/> </bean> </beans> Actual code: public class Repository { @Transactional public void save(Op op) { System.out.println("Transaction active:::: " + TransactionSynchronizationManager.isActualTransactionActive()); ... } } Calling code:

what does transaction mean in reference with neo4j database

不羁的心 提交于 2019-12-18 08:24:34
问题 I got a bit confuse with term transaction. Suppose in transaction A we have two commands C1 and C2 and same in transaction B. Now both transaction come at same time then Are these observations correct? All commands of transaction A C1 and C2 will be done first (assuming A enter first) , then only commands of transaction B will be executed. Any command of transaction A or B can be executed but with assurance that If any of the command fails of any of the transaction then that transaction will

Multiple Connections With Same Connection String Under A Single Transaction, Elevated Transaction?

别来无恙 提交于 2019-12-18 07:06:23
问题 When using ado.net, and creating multiple connections to a MS SQL Server database within a single transaction (using System.Transactions.TransactionScope), does System.Transactions elevate the transaction from the lightweight transaction manager to the distributed transaction coordinator (kernel transaction coordinator on Vista), even if the connection strings are the same for all of the connection objects? The documentation is somewhat ambiguous on this specific situation. It says the