SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[6.5.278] $COLUMNS()$ macro anomaly

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[6.5.278] $COLUMNS()$ macro anomaly
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post [6.5.278] $COLUMNS()$ macro anomaly Reply with quote
According to CHAPTER 7 - Using Macro-variables with Text Prefixes and Text Suffixes I'd expect the following snippet
Code:

u.$COLUMNS(vertical,sort)$

to have the following results for a table containing columns 'a', 'b' and 'c'
Quote:

u.a
u.b,
u.c,

but I get
Code:

u.a,
b,
c

Removing '.' correctly yields ua, ub, uc (vertically, of course). It seems that '.' does not obey when asked to be part of a prefix.
Fri Mar 21, 2014 8:20 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7854

Post Reply with quote
Please change the snippet code to "u."$COLUMNS(vertical,sort)$

If the prefix or suffix contains any spaces or non-alphanumeric characters, it needs to be taken in double quotes.
Sun Mar 23, 2014 10:10 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
Thanks, that worked. I tried to make an advanced version using
Code:

"$CURRENT(param1)$."$COLUMNS(vertical,sort)$

but it failed to comply. For "a snippettrigger" and selecting the table created earlier I get
Code:

"a."a
   "b
   "c


For the time being I replaced the snippet with this:
Code:

$$DECLARE @columns VARCHAR(MAX)
SET @columns = REPLACE(
' @$COLUMNS(vertical)$ ' , '@', '$CURRENT(param1)$.' )
SELECT  @columns$$

but it ruins the formatting. It would be really nice to have the more simple one-line version working.
Mon Mar 24, 2014 4:17 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7854

Post Reply with quote
I'm afraid the dynamic suffix version won't work, the suffix is unknown when $COLUMNS$ macro is evaluated. $COLUMNS$ is executed before $CURRENT$, then results of $CURRENT$ is added to the text.

As far as I understand, macros aren't executed sequentially. They are analyzed for inter-dependencies and then database dependent macros are executed first. For example, if you create a snippet with many macros having $OBJECT$ or $COLUMNS$ references , you still get a single prompt to select the target table name. As you see, the order in which macros appear in the snippet text is not important.
Mon Mar 24, 2014 8:08 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
Ohh, I see. Thanks for the explanation. Never mind, the replacement script works, I'll leave it that way.
Mon Mar 24, 2014 8:11 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.