SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Code snippet preprocess directive.

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Code snippet preprocess directive.
Author Message
Fluttershy



Joined: 27 Jan 2012
Posts: 2
Country: Russian Federation

Post Code snippet preprocess directive. Reply with quote
I... I have a little idea how to improve SQL Assistant. I don't want to say that SQL Assistant looks poor. But... But I hope it will be useful and it bring more harmony in SQL Assistant. Otherwise I'm really sorry for waisting your time, please don't be mad at me for this. Oh... Um... And "Hi" to you all.

Well you know sometimes I need to make conditional code in my snippet. So i do it like that:
Code:

$PROMPT(MakeSimpleRpt,Show all columns?,,,1 0,Yes No)$
select
$$
IF $MakeSimpleRpt$ = 0 SELECT
N'   *'
ELSE SELECT
N'   [Name]'
;
$$
from   sys.databases;

It looks a rather monstrous. I suggest to add a kind of preprocessor directives into snippets macro commands. Like that:
Code:

$PROMPT(MakeSimpleRpt,Show all columns?,,,1 0,Yes No)$
select
$#IF(MakeSimpleRpt = 0)#$
   *
$#ELSE#$
   [Name]
$#ENDIF#$
from   sys.databases;

Mon Dec 24, 2012 1:40 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7854

Post Reply with quote
Hi. Thank you for your suggestion. From the provided example I don't quite understand what a pre-processor could do better then a full fledged SQL dialect supported by your database server. Would you please provide couple more examples demonstrating the benefits of additional pre-processing directives?
Mon Dec 24, 2012 6:07 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Re: Code snippet preprocess directive. Reply with quote
Fluttershy wrote:
I... I have a little idea how to improve SQL Assistant. I don't want to say that SQL Assistant looks poor. But... But I hope it will be useful and it bring more harmony in SQL Assistant. Otherwise I'm really sorry for waisting your time, please don't be mad at me for this. Oh... Um... And "Hi" to you all.

Well you know sometimes I need to make conditional code in my snippet. So i do it like that:
Code:

$PROMPT(MakeSimpleRpt,Show all columns?,,,1 0,Yes No)$
select
$$
IF $MakeSimpleRpt$ = 0 SELECT
N'   *'
ELSE SELECT
N'   [Name]'
;
$$
from   sys.databases;

It looks a rather monstrous.


You could transcribe that into:
Code:

$PROMPT(MakeSimpleRpt,Show all columns?,,,1 0,Yes No)$
SELECT
$$
SELECT N'   ' +
   CASE $MakeSimpleRpt$
      WHEN 1 THEN N'*'
      WHEN 0 THEN N'[Name]'
   END
$$
FROM   sys.databases;

which is a bit less monstrous and also much more human readable at the same time.
Wed Jan 02, 2013 4:29 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.