 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
Fluttershy
Joined: 27 Jan 2012 Posts: 2 Country: Russian Federation |
|
Code snippet preprocess directive. |
|
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:
 |
 |
$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:
 |
 |
$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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
Re: Code snippet preprocess directive. |
|
 |
 |
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:
 |
 |
$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:
 |
 |
$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 |
|
 |
|
|
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
|
|
|