transactions

TransactionScope vs Transaction in LINQ to SQL

两盒软妹~` 提交于 2019-12-17 03:55:16
问题 What are the differences between the classic transaction pattern in LINQ to SQL like: using(var context = Domain.Instance.GetContext()) { try { context.Connection.Open(); context.Transaction = context.Connection.BeginTransaction(); /*code*/ context.Transaction.Commit(); } catch { context.Transaction.Rollback(); } } vs the TransactionScope object using (var context = Domain.Instance.GetContext()) using (var scope = new TransactionScope()) { try { /*code*/ scope.Complete(); } catch { } } 回答1:

Entity Framework 6 transaction rollback

﹥>﹥吖頭↗ 提交于 2019-12-17 03:53:46
问题 With EF6 you have a new transaction which can be used like: using (var context = new PostEntityContainer()) { using (var dbcxtransaction = context.Database.BeginTransaction()) { try { PostInformation NewPost = new PostInformation() { PostId = 101, Content = "This is my first Post related to Entity Model", Title = "Transaction in EF 6 beta" }; context.Post_Details.Add(NewPost); context.SaveChanges(); PostAdditionalInformation PostInformation = new PostAdditionalInformation() { PostId = (101),

How to start and end transaction in mysqli?

巧了我就是萌 提交于 2019-12-17 02:31:18
问题 As far as I understood transaction starts once we call $mysqli->autocommit(FALSE); statement and ends after calling $mysqli->commit(); command like in the example below. <?php //Start transaction $mysqli->autocommit(FALSE); $mysqli->query('UPDATE `table` SET `col`=2'); $mysqli->query('UPDATE `table1` SET `col1`=3;'); $mysqli->commit(); //End transaction //Executing other queries without transaction control $mysqli->query("Select * from table1"); $mysqli->query("Update table1 set col1=2"); /

MySQL AUTO_INCREMENT does not ROLLBACK

安稳与你 提交于 2019-12-16 22:22:32
问题 I'm using MySQL's AUTO_INCREMENT field and InnoDB to support transactions. I noticed when I rollback the transaction, the AUTO_INCREMENT field is not rollbacked? I found out that it was designed this way but are there any workarounds to this? 回答1: Let me point out something very important: You should never depend on the numeric features of autogenerated keys. That is, other than comparing them for equality (=) or unequality (<>), you should not do anything else. No relational operators (<, >)

Nested stored procedures containing TRY CATCH ROLLBACK pattern?

蓝咒 提交于 2019-12-16 19:53:25
问题 I'm interested in the side effects and potential problems of the following pattern: CREATE PROCEDURE [Name] AS BEGIN BEGIN TRANSACTION BEGIN TRY [...Perform work, call nested procedures...] END TRY BEGIN CATCH ROLLBACK TRANSACTION RAISERROR [rethrow caught error using @ErrorNumber, @ErrorMessage, etc] END CATCH END To the best of my understanding this pattern is sound when used with a single procedure - the procedure will either complete all of its statements without error, or it will

Make SQLAlchemy COMMIT instead of ROLLBACK after a SELECT query

非 Y 不嫁゛ 提交于 2019-12-14 04:18:24
问题 I am developing an app together with a partner. I do the database part ( PostgreSQL ), my partner implements the app on the web-server with python using SQLAlchemy . We make heavy use of stored procedures. A SELECT query on one of those looks like this in the db log: SET TRANSACTION ISOLATION LEVEL READ COMMITTED; SELECT col_a, col_b FROM f_stored_proc(E'myvalue'); ROLLBACK; In the stored procedures I write certain input to a log table. The app queries by SELECT , SQLAlchemy only sees a

NHIbernate affecting non-nhibernate queries?

有些话、适合烂在心里 提交于 2019-12-14 04:03:40
问题 I have got an odd problem with NHIbernate, and seeing as this is my first NHIbernate project I thought I'd ask the good people of StackOverflow.com. I'm following the 'Open session in view' pattern in ASP.Net, which opens a hibernate transaction on each request and commits it at the end of the request. This works fine normally, however on one of my pages, which is simply a read page not a write one, I get an issue. The page in question gets a list of projects, and does a few queries for

MYSQL | SP | CURSOR - Fetch cursor into variable return null

亡梦爱人 提交于 2019-12-14 03:59:26
问题 I want to: Create temporary table. Insert partial data into temporary table. Run in Loop on temporary.user_id field. Update each row after data manipulation and calculation. The problem on step #3, i get user_id=NULL instead an integer from cursor. CREATE PROCEDURE user_demo_sp() BEGIN DECLARE done INT DEFAULT FALSE; DECLARE current_user INT; DECLARE cur CURSOR FOR SELECT user_id FROM users_temp; -- Cursor on temp table DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; -- Create a table

Customer name incomplete on order confirmation

僤鯓⒐⒋嵵緔 提交于 2019-12-14 03:25:52
问题 Came across the following during a project: Customer fills out his/her name during checkout: Firstname Middlename Lastname The confirmation email sent contains incomplete name in the form of " Firstname Lastname " on the first sentence of the confirmation I looked at the mail templates and the function order.getCustomerName() does not seem to retrieve all the information. 回答1: You can set this in the customer address settings of admin. Admin → System → configuration → Customer Configuration →

WARNING: executing transaction with 0 enlisted resource: Bitronix

三世轮回 提交于 2019-12-14 03:19:36
问题 I am getting this warning "executing transaction with 0 enlisted resource" while executing a distributed transaction with Bitronix into two datasources. Can some one help to understand how to enlist resources to global transaction. My code is: import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import javax.sql.DataSource; import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicRollbackException; import javax.transaction