Menu

ExpectException results in ROLLBACK Error

2014-05-26
2014-05-28
  • Scott Heringer

    Scott Heringer - 2014-05-26

    Whenever I use ExpectException I receive the following error: (There was also a ROLLBACK ERROR --> The current transaction cannot be committed and cannot be rolled back to a savepoint. Roll back the entire transaction.{Private_RunTest,140})

    It appears that tSQLt is attempting a ROLLBACK after the fact that MSSQL has already performed the ROLLBACK due to the RAISERROR.

    I wrapped the following SELECT and SET statement in Private_RunTest with the following IF statement and it appeared to resolve the problem.

    IF ISNULL(@ExpectException,0) <> 1
    BEGIN
    SELECT @Msg = COALESCE(@Msg, '<NULL>') + ' (There was also a ROLLBACK ERROR --> ' +
    COALESCE(ERROR_MESSAGE(), '<ERROR_MESSAGE() is="" NULL="">') + '{' +
    COALESCE(ERROR_PROCEDURE(), '<ERROR_PROCEDURE() is="" NULL="">') + ',' +
    COALESCE(CAST(ERROR_LINE() AS NVARCHAR), '<ERROR_LINE() is="" NULL="">') + '})';
    SET @Result = 'Error';
    END

     
    • Dennis Lloyd Jr

      Dennis Lloyd Jr - 2014-05-28

      Hi Scott,

      I saw that you also posted on stack overflow and added a comment there:
      http://stackoverflow.com/questions/23876571/tsqlt-there-was-also-a-rollback-error-in-private-runtest

      It would be helpful to see more details of your test and the code you are
      testing.

      Thanks,
      Dennis

      On Mon, May 26, 2014 at 3:22 PM, Scott Heringer
      scottheringer@users.sf.netwrote:

      Whenever I use ExpectException I receive the following error: (There was
      also a ROLLBACK ERROR --> The current transaction cannot be committed and
      cannot be rolled back to a savepoint. Roll back the entire
      transaction.{Private_RunTest,140})

      It appears that tSQLt is attempting a ROLLBACK after the fact that MSSQL
      has already performed the ROLLBACK due to the RAISERROR.

      I wrapped the following SELECT and SET statement in Private_RunTest with
      the following IF statement and it appeared to resolve the problem.

      IF ISNULL(@ExpectException,0) <> 1
      BEGIN
      SELECT @Msg = COALESCE(@Msg, '') + ' (There was also a ROLLBACK ERROR -->
      ' +
      COALESCE(ERROR_MESSAGE(), '') + '{' +
      COALESCE(ERROR_PROCEDURE(), '') + ',' +
      COALESCE(CAST(ERROR_LINE() AS NVARCHAR), '') + '})';
      SET @Result = 'Error';
      END


      ExpectException results in ROLLBACK Errorhttps://sourceforge.net/p/tsqlt/discussion/845714/thread/d5a5d2ba/?limit=25#31f8

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/tsqlt/discussion/845714/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

Log in to post a comment.