Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6352567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:13:51+00:00 2026-05-24T22:13:51+00:00

Sup guys, is it possible for INSERT or UPDATE to throw an exception that

  • 0

Sup guys, is it possible for INSERT or UPDATE to throw an exception that would stop the procedure? I’m in a little bit of a pickle, because i’ve hanging transactions in what seems to be a bullet proof code.

    BEGIN TRANSACTION;

SET @sSystemLogDataId  = CONVERT(NCHAR(36), NEWID());
INSERT INTO crddata.crd_systemlogdata (systemdataid,systemlogid,userid,
    actiondatetime,actionstate)
    VALUES(@sSystemLogDataId,@inSystemLogId,@sUserId,GETDATE(),@nActionState);
SET @nError = @@ERROR;

IF (1 = @nChangeMassprintTaskStatus) AND (0 = @nError)
BEGIN
    UPDATE crddata.crd_massprinttasks SET massprinttaskstatus=@nMassprintTaskStatus
        WHERE massprinttaskid = @inMassprintTaskId;
    SET @nError = @@ERROR;
END

IF (@MassprintTaskType <> 1) AND (27 = @nActionState) AND (0 = @nError)
BEGIN
    UPDATE crddata.crd_massprinttasks SET massprinttasktype=1
        WHERE massprinttaskid = @inMassprintTaskId;
    SET @nError = @@ERROR;
END

IF 0 = @nError
BEGIN
    COMMIT TRANSACTION;
END
ELSE
BEGIN
    ROLLBACK TRANSACTION;
END 

Halp, anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:13:52+00:00Added an answer on May 24, 2026 at 10:13 pm

    Without TRY/CATCH, this is not bullet proof.

    Errors can be batch aborting (eg datatype conversions or errors thrown from triggers) which means ROLLBACK does not run.

    You have to use TRY/CATCH and I always use SET XACT_ABORT ON too

    SET XACT_ABORT, NOCOUNT ON;
    BEGIN TRY
    
        BEGIN TRANSACTION;
    
        SET @sSystemLogDataId  = CONVERT(NCHAR(36), NEWID());
        INSERT INTO crddata.crd_systemlogdata (systemdataid,systemlogid,userid,
            actiondatetime,actionstate)
            VALUES(@sSystemLogDataId,@inSystemLogId,@sUserId,GETDATE(),@nActionState);
    
        IF (1 = @nChangeMassprintTaskStatus)
        BEGIN
            UPDATE crddata.crd_massprinttasks SET massprinttaskstatus=@nMassprintTaskStatus
                WHERE massprinttaskid = @inMassprintTaskId;
        END
    
        IF (@MassprintTaskType <> 1) AND (27 = @nActionState)
        BEGIN
            UPDATE crddata.crd_massprinttasks SET massprinttasktype=1
                WHERE massprinttaskid = @inMassprintTaskId;
        END
    
        COMMIT TRANSACTION;
    END TRY
    BEGIN CATCH
        IF XACT_STATE() <> 0 --may already be rolled back by SET XACT_ABORT or a trigger
             ROLLBACK TRANSACTION;
        RAISERROR [rethrow caught error using ERROR_NUMBER(), ERROR_MESSAGE(), etc]
    END CATCH
    

    Mandatory background reading is Erland Sommarskog’s “Error Handling in SQL 2005 and Later”: we’ll test you on it later…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sup Guys, I Have a Function on my frmMain Class wich will update my
Possible Duplicate: relative font-size of <sub> or <sup> and their descendants in IE I'm
Sup guys. I'm using ajax to load in a bunch of data with php.
Sup guys. I'm loading data into a table using ajax and jquery. This can
Sup fellas, I am using the script that a fellow stack overflow user posted
Hey guys, I have this code within a function inside a class that is
I'm coding smt right now, and am a little bit peeved by the fact
Namely, how does the following code: var sup = new Array(5); sup[0] = 'z3ero';
I'm trying to create a function that searches up a WebControl's parent-child relationship (basically
I want to get the first letter of a string and I've noticed that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.