transactions

Using transaction on a single update statement

你离开我真会死。 提交于 2020-02-26 09:22:15
问题 I am dubbing some SP at work and I have discover that whoever wrote the code used a transaction on a single update statement like this begin transaction *single update statment:* update table whatever with whatever commit transaction I understand that this is wrong because transaction is used when you want to update multiple updates. I want to understand from the theoretical point, what are the implications of using the code as above? Is there any difference in updating the whatever table

Does SQL Server acquire locks even without an explicit transaction?

拟墨画扇 提交于 2020-02-24 09:22:11
问题 I was reading about MSSQL Locking for the first time, and it many places, the locking mechanism concepts depend on the existence of Transactions. I was wondering whether locking (in general) is possible without having any Transactions involved? 回答1: When no explicit transaction exists, each SQL statement is executed in an automatic (autocommit) transaction. Normal locking behavior will apply in that case and the locks released when the automatic transaction is completed as the statement

Save multiple models at a time in Yii2

最后都变了- 提交于 2020-02-24 04:31:30
问题 I have two models, Users and Students . I want to insert data into these tables simultaneously. First, I save data into Students model and then into Users models. Now, if data doesn't successfully get inserted into Users model there is already an entry into Students table. What I want is data entries into both model only if data can be successfully saved in both. Now my controller code looks something like this: public function actionCreate() { $model = new Students(); $userModel = new Users(

Save multiple models at a time in Yii2

孤者浪人 提交于 2020-02-24 04:31:06
问题 I have two models, Users and Students . I want to insert data into these tables simultaneously. First, I save data into Students model and then into Users models. Now, if data doesn't successfully get inserted into Users model there is already an entry into Students table. What I want is data entries into both model only if data can be successfully saved in both. Now my controller code looks something like this: public function actionCreate() { $model = new Students(); $userModel = new Users(

Fate of an ADO.Net Transaction when connection is suddenly broken

久未见 提交于 2020-02-15 08:30:42
问题 Consider the sample code below. If the connection to the database is suddenly broken when on STEP 2 (i.e. 2nd command), then even if we try to rollback the transaction it will not rollback since there is no connection to the database server. In such a case, what happens to the transaction object on the database server side? Will it remain in a waiting mode? I have had this situation come up when I tried to run a long transaction in ADO.Net by connecting to database servers through a VPN

Fate of an ADO.Net Transaction when connection is suddenly broken

纵然是瞬间 提交于 2020-02-15 08:28:26
问题 Consider the sample code below. If the connection to the database is suddenly broken when on STEP 2 (i.e. 2nd command), then even if we try to rollback the transaction it will not rollback since there is no connection to the database server. In such a case, what happens to the transaction object on the database server side? Will it remain in a waiting mode? I have had this situation come up when I tried to run a long transaction in ADO.Net by connecting to database servers through a VPN

where should ActiveRecord::Base.transaction be?

≯℡__Kan透↙ 提交于 2020-02-07 17:16:06
问题 I have three models: List, Food, and Quantity. List and Food are associated through Quantity via has_many :through. So each Quantity has three params: food_id, list_id, and amount (an integer). My aim is to create a new Quantity (associated with that list) each time a list is created. I wish to do this using a transaction so that all objects must be successfully created or else none will be. My main question is: where in my code should I write this transaction? I think it should be in the

Why do I get Error resulting in state DEAD in MongoDB?

痴心易碎 提交于 2020-02-06 15:07:39
问题 I’m working with multidocument mongodb transactions, and I’m getting an unexpected error. In my c++ app, using mongocxx driver, the steps I’m performing are the following: create session start transaction create a bulk_write 1 for this session, where I have multiple updates (~1000) to colletion 1 create another bulk_write 2 for this session, where I have multiple inserts (~1000) to collection 2 execute bulk_write 1 execute bulk write 2 commit transaction This is the code snippet for the

Do I want to minimize the scope of @Transactional?

ε祈祈猫儿з 提交于 2020-02-06 05:25:46
问题 Not sure if 'scope' is the correct term here. I am using Spring for JPA transaction management (with a Hibernate underneath). My method to preform database transaction is private, but since you can only set @Transactional on a class or on a public method Since this mechanism is based on proxies, only 'external' method calls coming in through the proxy will be intercepted. This means that 'self-invocation', i.e. a method within the target object calling some other method of the target object,

Do I want to minimize the scope of @Transactional?

不打扰是莪最后的温柔 提交于 2020-02-06 05:25:07
问题 Not sure if 'scope' is the correct term here. I am using Spring for JPA transaction management (with a Hibernate underneath). My method to preform database transaction is private, but since you can only set @Transactional on a class or on a public method Since this mechanism is based on proxies, only 'external' method calls coming in through the proxy will be intercepted. This means that 'self-invocation', i.e. a method within the target object calling some other method of the target object,