Questions tagged [sqltransaction]

An SQL-transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order. Executing SQL-statements in Transactions, can ensure data integrity and handle database errors.

An SQL-transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order.

A transaction is the propagation of one or more changes to the database. For example, creating, updating, or deleting a record from the table. Transactions are used to ensure data integrity and to handle database errors, by collecting SQL queries into a group and executing all of them together, as one unit of work.

Properties of Transactions: Transactions have the following four standard properties, usually referred to by the acronym ACID:

  • Atomicity: ensures that all operations within the work unit are completed successfully; otherwise, the transaction is aborted at the point of failure, and previous operations are rolled back to their former state.
  • Consistency: ensures that the database properly changes states upon a successfully committed transaction.
  • Isolation: enables transactions to operate independently of and transparent to each other.
  • Durability: ensures that the result or effect of a committed transaction persists in case of a system failure.
233 questions
0
votes
3 answers

C# TransactionManager

Hi I have a generator which made some automated code (creating all the get, set, etc) for me structured by a Database, in this code there is a piece of code that is as follows: SqlTransaction transaction = TransactionManager.GetTransaction(); I…
Orlando
  • 935
  • 2
  • 20
  • 42
0
votes
0 answers

SqlTransaction not allowing update row in table while inserting

I have created a demo application to understand the C# SqlTransaction. I have a table Region, and I have developed a Windows Forms application that starts two threads: THREAD 1: Start a transaction. Insert a record. Sleep for 60 seconds Commit the…
Yash
  • 356
  • 1
  • 5
  • 22
0
votes
0 answers

Effects on a ActiveRecord/PostgreSQL transaction when client is interrupted via Ruby Timeout::timeout

Before we start, yes, I know using Ruby's Timeout is a horrible idea. But this is more of a thought experiment. Let's say I have some Ruby code wrapped in a Timeout::timeout block that does a whole bunch of SQL transactions (via ActiveRecord), from…
Display name
  • 1,109
  • 1
  • 15
  • 31
0
votes
0 answers

Is there a way of side-stepping error #1442 in an INSERT trigger?

Problem: When a row is INSERTed, I must use a trigger to (conditionally) insert another row in the same table. I must put "NEW.rowID" in a different field of the "another" row (rowID being the primary key). Using the same table as the one that…
Henrik Erlandsson
  • 3,797
  • 5
  • 43
  • 63
0
votes
0 answers

SqlTransaction vs TransactionScope after SqlConnection is established

I know that there are a number of questions on the topic of SqlTransactions vs TransactionScopes, but I haven't seen any examples of using TransactionScopes after Sqlconnections have been opened. I'm writing a program that will have multiple SQL…
Brian
  • 137
  • 1
  • 6
0
votes
2 answers

SQL - Transactions Get Auto Increment Value Inside The Transaction

I have 2 tables, the first table contains the minor details on the item and the second table contains the rest of the information. BEGIN TRANSACTION; INSERT INTO Items (Name, CategoryId) VALUES ('My Tv', 5); INSERT INTO CharsToItem (ItemId,…
Adir
  • 29
  • 2
  • 9
0
votes
1 answer

Mybatis SQL session commit seemingly slower than following code

Background We have 2 services written in Java - one handles database operations on different files (CRUD on database), the other handles long-running processing of those records (complicated background tasks). Simply we could say they are producer…
Miroslav
  • 444
  • 1
  • 7
  • 21
0
votes
0 answers

How can I rollback child transaction when error occur in main transaction in .Net Core 2.1

I am using two different DB in my project(.Net Core 2.1). I am not able to rollback child transaction if error occurs in main transactions. Below are the steps: Open new connection with transaction for DB1 Perform update operation on patient table…
Nayan Rudani
  • 1,029
  • 3
  • 12
  • 21
0
votes
1 answer

SqlException on Commit() The transaction operation cannot be performed because there are pending requests working on this transaction

My SQL transaction throws exception on Commit(). This is the first time I use transactions with SqlCommands so maybe I'm making some error in code. I saw other questions regardings same error but none of them helped. I tried explicitly calling…
bigb055
  • 198
  • 3
  • 14
0
votes
0 answers

The commit transaction request has no corresponding begin transaction using ADO.net

I want to update the records batch wise in SqlTransaction. In every batch i am updating 50 records. If any one record fails to update i want rollback those 50 records. I have written this code in while loop. But i am getting following error…
0
votes
1 answer

SQL Server - Updating a table that has foreign keys, using DELETE/INSERT instead of UPDATE

I have a main table with many associated tables linked to it using an "id" foreign key. I need to update a row in this main table. Instead of updating all the fields of the row, one by one, it would be easier for me to simply deleting the whole row…
electrotype
  • 8,342
  • 11
  • 59
  • 96
0
votes
1 answer

Best practices of disposing of SqlConnection, SqlTransaction, SqlCommand, SqlDataAdapter objects

Are ALL the sqlCommand, sqlTransaction and sqlDataAdapter objects automatically disposed on exit from the "using" block (in which sqlConnection disposed) or all these objects to be disposed should be in separated nested "using" blocks, otherwise…
Ilan
  • 989
  • 2
  • 12
  • 22
0
votes
2 answers

SQL Transaction Set Temporary Value

I am relatively new to databases and SQL, and I am not clear on how or whether transactions may relate to a problem that I am trying to solve. I want to be able to temporarily set a value in a database table, run some query, and then clear out the…
grandinero
  • 1,155
  • 11
  • 18
0
votes
1 answer

SQL Log and ACTIVE TRANSACTIONS

I have a Web Server with SQL 2008 running a simulated SQL 2005 db, and I have a local SQL 2005 db for testing environment. This causes me to use scripts for backup/restoring data for testing as 2008 server backups do not restore to a 2005…
CraigJSte
  • 912
  • 6
  • 17
  • 33
0
votes
0 answers

Execute non query returns negetive one(-1) but still inserts

In my understanding, the execute nonquery command in C# SQLCommand has to return the number of affected records, I have used this SQLCommand with SQL Transaction, it return a negative one but when I check the database the record has been inserted.…
Mronzer
  • 399
  • 1
  • 7
  • 18