SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
SA Pro: 12.2.387 CTE semicolon throws off bracket matching

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
SA Pro: 12.2.387 CTE semicolon throws off bracket matching
Author Message
Mindflux



Joined: 25 May 2013
Posts: 838
Country: United States

Post SA Pro: 12.2.387 CTE semicolon throws off bracket matching Reply with quote
Code:
BEGIN
   BEGIN TRY
      BEGIN
         DECLARE @z AS INT;
         
         DECLARE foo CURSOR STATIC
         FOR
             SELECT bar
             FROM   baz
             WHERE  bar.ID = 'FOO'
         
         OPEN foo
         FETCH NEXT FROM foo INTO @z
         
         WHILE @@FETCH_STATUS = 0
         BEGIN
            ;WITH nohits AS ()
         END
         CLOSE foo
         DEALLOCATE foo
      END
   END TRY
END



If you paste this into SSMS or SA Editor

The "end" at line 18 matches with the begin at line 3, instead of line 16. If you remove the semicolon before the ;WITH statement the bracket matching works.
Likewise if you highlight begin try at line 2, it highlights the END at 21, instead of the END TRY at 22. Again removing the semicolon fixes it.


IIRC the semicolon is required to use a CTE in this manner, so can the bracket matching be fixed?
Wed Feb 22, 2023 3:36 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.