Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Idea for exception in transaction with just one ta

Author  Topic 

whitepear
Starting Member

24 Posts

Posted - 2014-04-21 : 05:24:15
Hello!

Please, I want to make simple transaction, (add 2 rows to single table) and to find CAUSE when to rollback it.

Please, any ideas, what might be the condition to make the think rollback to savepoint?

Many thanks!!!

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2014-04-21 : 06:27:32
A failure e.g. a constraint violation?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

whitepear
Starting Member

24 Posts

Posted - 2014-04-21 : 08:52:39
Hello!
I need idea for ANY failure that can occur!

I have a single table, 3 rows, transaction with savepoint adds next 2 rows ,so result is 5 rows.
I need EXAMPLE for ANY failure that would cause final output of just 3, and not 5 rows.

Please, can someone explain me constraint violation in simple terms, or give me an usefull link so that I kknow what it is and what I have to do to CAUSE such a failure in my one table program?

MANY THANKS- I APPOOGISE, STARTED LAST WEEK!!

Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2014-04-21 : 11:49:28
What do you mean by any failure - that you want a list of all conditions that can cause a statement to fail? If so then you won't get that.

A transaction will ensure that all rows will be inserted or none of them and a try catch block will trap trapable errors - those which cause a connection failure will not be trapped but the transaction will (or should not) commit.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

whitepear
Starting Member

24 Posts

Posted - 2014-04-21 : 13:13:44
Hello!
Please, is connection errror (disconnection) ment on the "others" list?

In that case, the rollback works, doesn't it?

Go to Top of Page
   

- Advertisement -