SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Improper formatting of nested IF statements

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Improper formatting of nested IF statements
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Improper formatting of nested IF statements Reply with quote
The following definition for formatting IF statements has problems formatting nested IFs properly:

Formatting def for IF BEGIN...ELSE:
Code:

IF   ...
AND   ...
OR   ...
BEGIN
   <stmtList>
END
ELSE
BEGIN
   <stmtList>
END

Also, there's another formatting definition for simple IF:
Code:

IF   ...
AND   ...
OR   ...
   ...
ELSE
   ...


Code to be formatted:
Code:

IF   OBJECT_ID('dbo.sp_nyomvonal_tetel_atvetel') IS NOT NULL
BEGIN
PRINT 'DROP PROCEDURE dbo.sp_nyomvonal_tetel_atvetel'
DROP PROCEDURE dbo.sp_nyomvonal_tetel_atvetel
IF   @@ERROR = 0
PRINT 'PROCEDURE dbo.sp_nyomvonal_tetel_atvetel dropped'
END


The desired result:
Code:

IF   OBJECT_ID('dbo.sp_nyomvonal_tetel_atvetel') IS NOT NULL
BEGIN
   PRINT 'DROP PROCEDURE dbo.sp_nyomvonal_tetel_atvetel'
   DROP PROCEDURE dbo.sp_nyomvonal_tetel_atvetel
   IF   @@ERROR = 0
      PRINT 'PROCEDURE dbo.sp_nyomvonal_tetel_atvetel dropped'
END

Actual esult:
Code:

IF   OBJECT_ID('dbo.sp_nyomvonal_tetel_atvetel') IS NOT NULL
BEGIN
   PRINT 'DROP PROCEDURE dbo.sp_nyomvonal_tetel_atvetel'
   DROP PROCEDURE dbo.sp_nyomvonal_tetel_atvetel
   IF   @@ERROR = 0 PRINT 'PROCEDURE dbo.sp_nyomvonal_tetel_atvetel dropped'
   END

with the closing END misaligned.


The inner if should be transformed from:
Code:

IF   @@ERROR = 0 PRINT 'PROCEDURE dbo.sp_nyomvonal_tetel_atvetel dropped'

into
Code:

   IF   @@ERROR = 0
      PRINT 'PROCEDURE dbo.sp_nyomvonal_tetel_atvetel dropped'

as well, but it isn't. This latter might be the result of an incorrect definition for simple IFs but the former should definitely work. Actually, they both should, at least they did so in the previous version (if I recall correctly). It seems that something has been broken.
Thu Jun 14, 2012 9:14 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
Thank you. I can reproduce the same results. We will look into that.
Thu Jun 14, 2012 10:30 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
Seems to be fixed in 6.2.112, thank you very much!
Fri Jun 22, 2012 4:27 am 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.