locked
Determining SelectNewAnchorCommand value with multiple tables RRS feed

  • Question

  • I've got around 50 tables I'd like to sync with one sync operation. Since SelectNewAnchorCommand belongs to the ServerProvider rather than the SyncAdapter, what is the best way to determine a new anchor? Do I need to query each table to find the latest modified/created timestamp?

     

    Dave

    • Moved by Max Wang_1983 Friday, April 22, 2011 7:29 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Thursday, November 22, 2007 12:12 AM

Answers

  • Hi Dave,

     

    No, I don't think that you need to loop through all the tables to find the anchor. The most common Anchor type is the timestamp (in SQL and Oracle too) this datatype is monotonically increasing for any write operation that you do database-wide. That said, all you need to do to get the new anchor is to inquire the current timestamp.

     

    Thanks

     

    Thursday, November 22, 2007 11:02 PM
  • You have three options:

     

    1. Use the TIMESTAMP data type which is guaranteed to always give you a unique number that increases every time you retrieve a new value.  Think of it like a database wide identity field.  As Rafik mentioned, there should be some equivalent for Oracle as all database vendors include this feature.
    2. Use date time and modify your anchor command to get the current date
    3. Use the SQL Server 2008 change tracking feature that tracks changes for you automatically.

     

    For a good description of anchor's, see the section entitled Determining Which Data Changes to Download to a Client here:

     

    http://msdn.microsoft.com/en-us/library/cc305973(SQL.100).aspx

     

    No need to ever iterate through your tables and get max value unless I am missing something.

     

    Sean Kelley

    Program Manager

    Microsoft

     

     

    Friday, May 23, 2008 1:34 PM
    Moderator

All replies

  • Hi Dave,

     

    No, I don't think that you need to loop through all the tables to find the anchor. The most common Anchor type is the timestamp (in SQL and Oracle too) this datatype is monotonically increasing for any write operation that you do database-wide. That said, all you need to do to get the new anchor is to inquire the current timestamp.

     

    Thanks

     

    Thursday, November 22, 2007 11:02 PM
  • It looks to me like I don't need to do any special work on the client - any change in any table gets recognized by SyncServices. But on the Oracle side of things, I'm needing to get the MAX from the modified and created timestamp columns for all tables for SyncServices to realize that a change has happened.

     

    If this is not required, what am I doing wrong?

     

    Monday, November 26, 2007 4:24 PM
  • I didn't see an answer to this, and am struggling with the same question. I think I'll have to instantiate the sync components multiple times (i.e. kick off multiple sync 'event's) so that I can get a MAX from each table that I need to sync with.  Is my understanding correct?

    Thursday, May 22, 2008 6:59 PM
  • You have three options:

     

    1. Use the TIMESTAMP data type which is guaranteed to always give you a unique number that increases every time you retrieve a new value.  Think of it like a database wide identity field.  As Rafik mentioned, there should be some equivalent for Oracle as all database vendors include this feature.
    2. Use date time and modify your anchor command to get the current date
    3. Use the SQL Server 2008 change tracking feature that tracks changes for you automatically.

     

    For a good description of anchor's, see the section entitled Determining Which Data Changes to Download to a Client here:

     

    http://msdn.microsoft.com/en-us/library/cc305973(SQL.100).aspx

     

    No need to ever iterate through your tables and get max value unless I am missing something.

     

    Sean Kelley

    Program Manager

    Microsoft

     

     

    Friday, May 23, 2008 1:34 PM
    Moderator
  • Sean,

     

    Thanks for your response and apologies for a tardy reply; I was the one missing something.  I was being a bit daft when I submitted my query as I was thinking the server time would not work.

     

    A quick bit about my scenario: I am synchronizing a WinForms client with Siebel (running on Oracle 9i) and am unable to change the schema. Every table has a last updated and created columns (Date type).   Given that I am unable to change the schema to use the Timestamp type instead, I will just grab the current date from the server and use that.

     

    Thanks again!

    Monday, June 2, 2008 8:23 PM