On-demand training: More Gems from the SQL Prompt Treasure Chest. Watch now.

v 7.1.0.112 bug

jsreynolds1jsreynolds1 Posts: 68 Bronze 3
edited October 22, 2015 5:06AM in SQL Prompt
Hello,

version 7.1.0.112 (beta).

Basically "THROW;" gets placed into brackets.

If I reformat this:
SET NOCOUNT ON;

 BEGIN TRY
    
    BEGIN TRANSACTION;	

    COMMIT TRANSACTION;

END TRY
BEGIN CATCH
    IF @@TRANCOUNT > 0
        ROLLBACK TRANSACTION

			THROW;

END CATCH;

I get this:
SET NOCOUNT ON;

BEGIN TRY
    
    BEGIN TRANSACTION;	

    COMMIT TRANSACTION;

END TRY
BEGIN CATCH
    IF @@TRANCOUNT > 0
        ROLLBACK TRANSACTION

			[THROW];

END CATCH;

Comments

  • Hi John,

    This mirrors the behaviour of SQL Server.

    Because the THROW is right after the ROLLBACK TRANSACTION, it thinks that THROW is the name of the transaction you want to rollback.

    If you put a semicolon after ROLLBACK TRANSACTION, it should work as expected.

    Best regards,

    David
  • Ahh. I was relying on the formatting to do that for me.

    One ponders who would create a transaction called, "THROW", but then...
  • Hi John,

    It seems weird, but I feel that Prompt shouldn't make assumptions about what the writer meant.

    There are however requests to add in static analysis rules (one request is here). A semicolon after ROLLBACK TRANSACTION could be shown as a hint.

    Best regards,

    David
Sign In or Register to comment.