views:

32

answers:

0

Hello all,

Let say, I have a table with 2 columns (OrderId and OrderDate). In the original design, OrderId is the surrogate (which is still somewhat meaningful to the end user since they still like to refer to OrderNumber 12345) PK with IDENTITY integer. Since we start to adopt SyncFx and to support offline client creation scenario, we decided to add a new column unique identifier (GUID) as the new PK.

in my old working V1.0 implementation, the OrderId will be assigned as negative value (-1, -2 and so on) for the offline created records. when the sync happens, the OrderId will be reassigned with the 'next' number ( the server will perform the max() + 1 on the OrderId column in the table). the logic is implemented as a Stored procedure and it will be called during the insert trigger.

Update INSERTED

set OrderId = b.NextNumber

FROM INSERTED a,

(

SELECT SyncGUID,

ROW_NUMBER() OVER (ORDER BY SyncGUID) + (SELECT MAX(OrderId) MaxID FROM Order) as NextNumber

--select *

FROm Order

where OrderId <= 0

) b

where a.SyncGUID = b.SyncGUID

However, in V2.0, after the syc, the record is created in the server side and the OrderId did being updated (from -1 to 'next' number); however, that update change didn’t get download to the client. I was wondering

1) i looking into the logic in the _selectchanges() SProc. i seems like i might need to manually manipulate the [local_update_peer_timestamp] in order for the enumeration to pick it up ?!

2) since the whole logic is running within the insert trigger (which the record is still not committed to the actual table), I am also wondering is it possible to have the enumeration being called again after the record is committed to the server table. (without calling another sync)

3) will the "INSTEAD OF INSERT" trigger offer any helps in this case?! I tried a few time but no workies with my limited knowledge.

Any comments would be greatly appreciated?

Thanks,

--alex