SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[SA 9.0.166 Pro] - $COLUMN$ formatting issue

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[SA 9.0.166 Pro] - $COLUMN$ formatting issue
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 1401

Post [SA 9.0.166 Pro] - $COLUMN$ formatting issue Reply with quote
I've got the following snippet:
Code:

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
Code:

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:
Code:

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
Code:

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 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.