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;
jsreynolds1
0

Comments

3 comments

  • David Priddle
    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
    David Priddle
    0
  • jsreynolds1
    Ahh. I was relying on the formatting to do that for me.

    One ponders who would create a transaction called, "THROW", but then...
    jsreynolds1
    0
  • David Priddle
    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
    David Priddle
    0

Add comment

Please sign in to leave a comment.