473,382 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

ROLLBACK in SQL in a Spring Transaction

BarryA
19 16bit
I need to execute a SQL Server stored procedure from Java/Spring, and the SP has a try/catch block that logs errors to a table. The logging is required because the SP is also called manually or from a database task, however in my case, it creates an issue because the call from Spring is transactional (see https://stackoverflow.com/a/15984867/302151).

Is a ROLLBACK in the catch block sufficient to address my problem, and if so, is it a good practice? I mean:
Expand|Select|Wrap|Line Numbers
  1. BEGIN CATCH
  2.   IF XACT_STATE() != 0
  3.     ROLLBACK TRAN
  4.   INSERT INTO TBL_ERROR ...
  5. END CATCH
I read the scaler post, but I'm not sure if it's feasible to execute SQL SP from Spring without an automatically formed transaction.
What is the proposed solution if it does not work?
Apr 26 '23 #1
0 9157

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Alice | last post by:
Hi all, I have a problem with rollback segment. I am a beginner and do not have much knowledge of DBA. Anyways, the problem is there is a transaction of around 105 MB. This would not fit...
0
by: Brent Mondoux | last post by:
Hey everyone, I have a set of stored procedures that call each other to perform a set of tasks. I have decided to do this for database performance reasons rather than doing it from a ColdFusion...
3
by: john smile | last post by:
When a workstation losts connection to server, it can leave an uncomplete transaction. Then SQL Server removes the transaction. Could anyone guide me how to set the delay before SQL Server do it...
2
by: Alexander Korovyev | last post by:
Hello! It seems like I have some misunderstanding about the way transactions work and would appreceate your help. I want to delete records from 2 tables. Some records may not be deleted due...
0
by: perspolis | last post by:
I used a transaction in my application. and when an error occures the transaction rollback. but one of my columns is calculated column and I use the Expression property for that column. when I...
1
by: Jason Huang | last post by:
Hi, I am just wondering how do we test the transaction's Commit and Rollback? How do we simulate a situation to let the transaction fail then Rollback? Thanks for help. Jason
2
by: Dano | last post by:
Hi all! Perhaps a wise soul can help me here. I have an insert routine for an ASP.Net application and it works fine, but I decided to test the transaction rollback capabilities by stopping the...
2
by: campbell_canuck | last post by:
Hello and TIA, I am trying to write some VB code to move some data between 2 Access databases using a code module in Access. As part of it, I am trying to use transactions. However, by the...
3
by: tom c | last post by:
In Access SQL, is there a way to rollback a transaction?
2
by: NarutoFanatic | last post by:
Hello, I'm having trouble using a transaction - rollback statement in sql. I can't seem to have the rollback executed during an error when i've altered a table to add a column with the same name...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.