 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
[6.5.278] $COLUMNS()$ macro anomaly |
|
According to CHAPTER 7 - Using Macro-variables with Text Prefixes and Text Suffixes I'd expect the following snippet
 |
 |
u.$COLUMNS(vertical,sort)$
|
to have the following results for a table containing columns 'a', 'b' and 'c'
 |
 |
u.a
u.b,
u.c,
|
but I get
 |
 |
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Thanks, that worked. I tried to make an advanced version using
 |
 |
"$CURRENT(param1)$."$COLUMNS(vertical,sort)$
|
but it failed to comply. For "a snippettrigger" and selecting the table created earlier I get
 |
 |
"a."a
"b
"c
|
For the time being I replaced the snippet with this:
 |
 |
$$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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
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 |
|
 |
|
|
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
|
|
|