![SoftTree Technologies](templates/GreenTech/images/logo.gif) |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2109
|
|
[SA 9.0.166 Pro] - $COLUMN$ formatting issue |
|
I've got the following snippet:
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
DECLARE @datum_tol SMALLDATETIME = ?
-- ,@last_sync_version BIGINT = 0
-- ,@min_valid_version BIGINT = CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID('$OBJECT(TABLE)$'))
-- ,@current_version BIGINT = ? -- CHANGE_TRACKING_CURRENT_VERSION()
;
SELECT
d.$COLUMNS(vertical)$
,c.SYS_CHANGE_VERSION
,c.SYS_CHANGE_CONTEXT
FROM
$OBJECT(TABLE)$ AS d
CROSS APPLY
CHANGETABLE(VERSION $OBJECT(TABLE)$ ,( $COLUMNS(KEY)$ ) ,( d.$COLUMNS(KEY)$ )) AS c
WHERE 1 = 1
AND (c.SYS_CHANGE_VERSION <= @current_version OR c.SYS_CHANGE_VERSION IS NULL)
AND (@datum_tol <= d.datum_tol OR d.datum_ig IS NULL OR (d.datum_tol <= @datum_tol AND @datum_tol <= d.datum_ig))
;
|
When I select one of my tables (having a composite primary key of nyomvon_id and datum_tol) from the popup, I get
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
DECLARE @datum_tol smalldatetime = ?
-- ,@last_sync_version BIGINT = 0
-- ,@min_valid_version BIGINT = CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID('dbo.nyomvon'))
-- ,@current_version BIGINT = ? -- CHANGE_TRACKING_CURRENT_VERSION()
;
SELECT
d.nyomvon_id
,d.vonal_id
,d.nyomvonal
,d.helyi_nyomvonal
,d.nyomvon_nev
,d.Vv_kod
,d.aktiv_e
,d.datum_tol
,d.datum_ig
,d.irany
,d.dijszabas_tipus
,d.dij_vonal
,c.SYS_CHANGE_VERSION
,c.SYS_CHANGE_CONTEXT
FROM
dbo.nyomvon AS d
CROSS APPLY
CHANGETABLE(VERSION dbo.nyomvon ,(nyomvon_id ,datum_tol) ,(d.nyomvon_id ,d.datum_tol)) AS c
WHERE 1 = 1
AND (c.SYS_CHANGE_VERSION <= @current_version OR c.SYS_CHANGE_VERSION IS NULL)
AND (@datum_tol <= d.datum_tol OR d.datum_ig IS NULL OR (d.datum_tol <= @datum_tol AND @datum_tol <= d.datum_ig))
;
|
which is the expected result. Note that the CHANGETABLE function call is on a single row.
If I change the snippet by commenting some lines to:
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
DECLARE @datum_tol SMALLDATETIME = ?
-- ,@last_sync_version BIGINT = 0
-- ,@min_valid_version BIGINT = CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID('$OBJECT(TABLE)$'))
-- ,@current_version BIGINT = ? -- CHANGE_TRACKING_CURRENT_VERSION()
;
SELECT
d.$COLUMNS(vertical)$
-- ,c.SYS_CHANGE_VERSION
-- ,c.SYS_CHANGE_CONTEXT
FROM
$OBJECT(TABLE)$ AS d
--CROSS APPLY
-- CHANGETABLE(VERSION $OBJECT(TABLE)$ ,( $COLUMNS(KEY)$ ) ,( d.$COLUMNS(KEY)$ )) AS c
WHERE 1 = 1
-- AND (c.SYS_CHANGE_VERSION <= @current_version OR c.SYS_CHANGE_VERSION IS NULL)
AND (@datum_tol <= d.datum_tol OR d.datum_ig IS NULL OR (d.datum_tol <= @datum_tol AND @datum_tol <= d.datum_ig))
;
|
the snippet for the same table yields
![](templates/GreenTech/images/code_header.gif) |
![](templates/GreenTech/images/spacer.gif) |
DECLARE @datum_tol smalldatetime = ?
-- ,@last_sync_version BIGINT = 0
-- ,@min_valid_version BIGINT = CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID('dbo.nyomvon'))
-- ,@current_version BIGINT = ? -- CHANGE_TRACKING_CURRENT_VERSION()
;
SELECT
d.nyomvon_id
,d.vonal_id
,d.nyomvonal
,d.helyi_nyomvonal
,d.nyomvon_nev
,d.Vv_kod
,d.aktiv_e
,d.datum_tol
,d.datum_ig
,d.irany
,d.dijszabas_tipus
,d.dij_vonal
-- ,c.SYS_CHANGE_VERSION
-- ,c.SYS_CHANGE_CONTEXT
FROM
dbo.nyomvon AS d
--CROSS APPLY
-- CHANGETABLE(VERSION dbo.nyomvon ,( nyomvon_id, datum_tol ) ,( d.nyomvon_id,
d.datum_tol )) AS c
WHERE 1 = 1
-- AND (c.SYS_CHANGE_VERSION <= @current_version OR c.SYS_CHANGE_VERSION IS NULL)
AND (@datum_tol <= d.datum_tol OR d.datum_ig IS NULL OR (d.datum_tol <= @datum_tol AND @datum_tol <= d.datum_ig))
;
|
which in turn is a syntax error, the part "d.datum_tol )) as c" now being "broken away" from the CHANGETABLE line that's commented.
At first I thought it's related to the Code Formatting Style assigned to the snippet, but the Line Length for Code Wrapping is set to 200 for that formatting rule, so that should not cause any problems.
|
|
Sat Oct 22, 2016 1:59 pm |
|
![](templates/GreenTech/images/spacer.gif) |
|
|
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
|
|
|