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
5
votes
1 answer

How to achieve consistent read across multiple SELECT using AWS RDS DataService (Aurora Serverless)

I'm not sure how to achieve consistent read across multiple SELECT queries. I need to run several SELECT queries and to make sure that between them, no UPDATE, DELETE or CREATE has altered the overall consistency. The best case for me would be…
5
votes
2 answers

TransactionScope/SqlTransaction timeout extension

Is it possible to extend the timeout of a transaction (with SQL Server) once the transaction has started?
enashnash
  • 1,578
  • 1
  • 15
  • 36
5
votes
3 answers

How to check if Dotnet transaction is rolled back?

How Can I check if a dotnet transaction is closed or not ?
Relativity
  • 6,690
  • 22
  • 78
  • 128
5
votes
1 answer

Commit Transaction take too long?

I have a stored procedure that have the following code: BEGIN TRY --BEGIN TRANSACTION @TranName DECLARE @ID int INSERT INTO [dbo].[a] ([Comment],[Type_Id],[CreatedBy]) VALUES ('test',1,2) SET @ID = SCOPE_IDENTITY() INSERT…
5
votes
1 answer

Single SqlConnection with Transaction, multiple commands situation

I'm trying to use only a single connection and run two commands together, one using transaction and one without. The one without is a trace/logging function as this solution is deployed in another location. So that when the process fails partly I…
Uknight
  • 711
  • 6
  • 9
4
votes
1 answer

SQL Try/Catch logic with nested transactions

The following sproc is implemented in accord with the template in this article: Exception handling and nested transactions. This sproc is supposed to handle deadlocks and it is called by another sproc that already creates a transaction. Some magic…
4
votes
1 answer

PostgreSQL: Serializable transactions with GRANT/DROP role

I have been reading a lot about serializable transactions in Postgres, but came across an issue that I haven't been able to resolve. Let's assume that I have two Postgres sessions A and B from different psql processes, and that before starting any…
kolistivra
  • 4,229
  • 9
  • 45
  • 58
4
votes
3 answers

When should I use a SQLTransaction

What is the appropriate time to use a SQLTransaction? I use them for all of my INSERT, UPDATE and DELETE statements. Is this the correct usage or am I doing a bit of overkill?
Popeye
  • 43
  • 3
4
votes
0 answers

MySQL: Executing LOAD statements inside Transaction from a sql script file

I want to load my tables from some csv files. I want all the data import to be transaction bound i.e., if error occurs in any of the data import, all records loaded in other tables are also rolled back. The load statements are executed from a sql…
Pratap
  • 655
  • 2
  • 10
  • 20
4
votes
1 answer

SQL Server Sequence Gaps

I have a SEQUENCE that I used to set the transaction folio of a table: CREATE SEQUENCE [Seq].[Folio] AS [bigint] START WITH 114090 INCREMENT BY 1 MINVALUE -9223372036854775808 MAXVALUE 9223372036854775807 CACHE Today just for curiousity I…
VAAA
  • 14,531
  • 28
  • 130
  • 253
4
votes
1 answer

Transaction handling in Trigger (TRY/CATCH....XACT_ABORT ON)

I have the process scenario on SQL Server 2008R2: • A usp to gather data and then a transfer data between two SQL Servers This process is to be done with transaction at all levels of the process (usp, SSIS, and trigger) In the data flow…
4
votes
1 answer

How do transactions work with node-postgres?

I'm using node-postgres to make SQL queries with callback style. I have a function that takes in a list of queries and executes them within a transaction block. My understanding is that I submit the query "BEGIN" using node-postgres, submit all the…
ferson2020
  • 3,015
  • 3
  • 18
  • 26
3
votes
2 answers

SQL Server - Any better alternative to improve performance of a lengthy transaction with lot of inserts?

I have a scenario where a user action on screen results in new records getting created in about 50 different tables, real-time. The design of the use case is such that the new records that are created as a result of a user action - is required…
Lalman
  • 946
  • 2
  • 11
  • 27
3
votes
0 answers

.NET Core EF Use Same Transaction over multiple services throws cannot issue save transaction when there is no active transaction

In the .NET core web API application we are using MS SQL transactions in one service method and in the middle of that method, we are calling another service method, inside this method when trying to insert a new model entry it throws errors like "…
3
votes
5 answers

SQLite error: cannot start a transaction within a transaction with very basic tables

I am brand new to SQL, and I am learning on an SQLite editor. So I create a couple of very simple tables. This code is straight from Linkedin learning "SQL essential training", and I am using the recommended SQLite editor. CREATE TABLE…
Jabernet
  • 381
  • 2
  • 4
  • 19
1
2
3
15 16