transactions

.NET TransactionScope class and T-SQL TRAN COMMIT and ROLLBACK

血红的双手。 提交于 2019-12-17 20:48:37
问题 I am current writing an application that will require multiple inserts, updates and deletes for my business entity. I am using the TransactionScope class to guarantee all the stored procedures can commit or roll back as a single unit of work. My question is, I am required to also use COMMIT TRAN and ROLLBACK TRAN is each of my stored procedures if I am using the TransactionScope class in my .NET class library? 回答1: ON 2005 its not necessary, on 2000 I would ,Also, i usually put the

Multiple database and transactions

最后都变了- 提交于 2019-12-17 20:27:58
问题 If i use two database, i have to start to transaction? Is this correct, or this code is wrong? If i make a mistake in the second query, then call rollback(), but unfortunately won't roll back the first query... $conn_site=mysql_connect("localhost", "us", "ps"); mysql_select_db("site",$conn_site); $conn_forum=mysql_connect("localhost", "us", "ps"); mysql_select_db("forum",$conn_forum); function begin() { @mysql_query("BEGIN",$conn_site); @mysql_query("BEGIN",$conn_forum); } function commit_reg

Having TRANSACTION In All Queries

喜你入骨 提交于 2019-12-17 20:19:54
问题 Do you think always having a transaction around the SQL statements in a stored procedure is a good practice? I'm just about to optimize this legacy application in my company, and one thing I found is that every stored procedure has BEGIN TRANSACTION . Even a procedure with a single select or update statement has one. I thought it would be nice to have BEGIN TRANSACTION if performing multiple actions, but not just one action. I may be wrong, which is why I need someone else to advise me.

Spring @Transactional method - participating transaction

依然范特西╮ 提交于 2019-12-17 19:46:21
问题 in one dao I have 2 @Transactional methods. if i do not provide any explicit properties, then what will happen, if I run one method in the body of another? Both methods will run within THE SAME ONE TRANSACTION? 回答1: Proxies in Spring AOP When using Transactional, you're dealing with proxies of classes, so in this scenario: @Transactional public void doSomeThing(){ // calling this method targets a proxy doSomeThingElse(); // this method targets the actual class, not the PROXY, // so the

Mysql deadlock explanation needed

不想你离开。 提交于 2019-12-17 19:35:28
问题 I received the following deadlock log via "SHOW INNODB STATUS". Can someone care to explain why the transaction was aborted? It seems that Transaction 2 is holding the lock, but is also stuck requesting the same lock (except for the "waiting" part), which leads to a deadlock when Transaction 1 requires it as well. ===================================== 091205 6:25:01 INNODB MONITOR OUTPUT ===================================== Per second averages calculated from the last 39 seconds ----------

Is there a way to use TransactionScope with an existing connection?

强颜欢笑 提交于 2019-12-17 19:27:21
问题 I have some code that works like the advised use of TransactionScope, but has an ambient connection instead of an ambient transaction. Is there a way to use a TransactionScope object with an existing connection, or is there an alternative in the .Net framework for this purpose? 回答1: In fact, there is one way. connection.EnlistTransaction(Transaction.Current) It works and it doesnt promote transaction to distributed if not necessary (contrary to what documentation says) HTH 回答2: To enlist a

How do you get around multiple database connections inside a TransactionScope if MSDTC is disabled?

北慕城南 提交于 2019-12-17 18:59:21
问题 I have a web application that issues requests to 3 databases in the DAL. I'm writing some integration tests to make sure that the overall functionality round trip actually does what i expect it to do. This is completely separate from my unit tests, just fyi. The way I was intending to write these tests were something to the effect of this [Test] public void WorkflowExampleTest() { (using var transaction = new TransactionScope()) { Presenter.ProcessWorkflow(); } } The Presenter in this case

How can I tell if I have uncommitted work in an Oracle transaction?

倾然丶 夕夏残阳落幕 提交于 2019-12-17 18:53:07
问题 Is there a way to tell if I have uncommitted work (ie DML) in a transaction? Maybe a data-dictionary view I can query? A method to find this out both from within and outside of the session running the open transaction would be welcome. Thank you 回答1: SELECT * FROM v$session v WHERE v.AUDSID = userenv('sessionid') AND v.TADDR IS NOT NULL 回答2: If you don't have access to v$session you can use select dbms_transaction.local_transaction_id from dual; This only works from within the session but

Firebase how to prevent duplicate entries atomically

℡╲_俬逩灬. 提交于 2019-12-17 18:44:47
问题 I'm looking at using firebase as a data store for user data for a web app. My current thought is to store each user's data using the timestamp of when they joined as the key referencing that user's data. The advantage of this scheme is that it's a simple way to assign unique integer ids to users, and makes chronological sorting of users simple. A downside, however, is that if two "add user" requests are submitted with identical data, the app will happily add two separate entries, which is

Transaction in REST WCF service

℡╲_俬逩灬. 提交于 2019-12-17 18:24:20
问题 We are having a REST WCF service. we want the save operation on this REST service to be in transaction. Is there a way to pass Transaction object over the wire to REST WCF service? 回答1: Here is a quote from Roy Fielding, the guy who invented the term REST If you find yourself in need of a distributed transaction protocol, then how can you possibly say that your architecture is based on REST? I simply cannot see how you can get from one situation (of using RESTful application state on the