SyBase SQL Anywhere 检查是否需要同步?

发布于 2024-08-14 04:14:02 字数 275 浏览 6 评论 0原文

我有一个 Sybase SQL Anywhere 11.0.1 数据库,用于与 Oracle Consolidated Database 同步。

我知道 SQL Anywhere 数据库会跟踪对其所做的所有更改,以便它知道要与统一数据库同步哪些内容。我的问题是是否有一个 SQL 命令可以告诉您数据库是否有要同步的更改。

我有一个移动应用程序,我想在用户对需要同步的手持设备进行更改时向他们显示一个小标志。我可以自己创建另一个表来跟踪这些内容,但我宁愿只是 ping 数据库并询问它是否有需要同步的更改。

I have a Sybase SQL Anywhere 11.0.1 database that I am using to sync with an Oracle Consolidated Database.

I know that the SQL Anywhere database keeps track of all of the changes that are made to it so that it knows what to synchronize with the consolidated database. My question is whether or not there is a SQL command that will tell you if the database has changes to sync.

I have a mobile application and I want to show a little flag to the user anytime they have made changes to the handheld that need to be synced. I could just create another table to track that stuff myself but I would much rather just ping the database and ask it if it has changes that need to be synced.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫瑟鸿黎 2024-08-21 04:14:02

没有任何东西会自动告诉您有数据需要同步。除了 Ben 的建议之外,另一个想法是查询远程数据库中的 SYS.SYSSYNC 表以了解是否可能发生更改。以下语句返回一个结果集,其中显示上次同步的简单状态

select ss.site_name, sp.publication_name, ss.log_sent,ss.progress 
from sys.syssync ss, sys.syspublication sp 
where ss.publication_id = sp.publication_id
and ss.publication_id is not null 
and ss.site_name is not null

: log_sent,则上次同步的状态未知。上次上载可能已在合并时应用,也可能未应用,因为上载已发送,但未从 MobiLink 服务器收到响应。在这种情况下,建议同步并不是一个坏主意。

如果progress = log_sent,则上次同步成功。知道了这一点,您可以检查 db_property('CurrentRedoPos') 的值,它将返回远程数据库的当前日志偏移量。如果该值明显高于进度值,则说明自上次同步以来已对数据库应用了许多操作,因此很可能有数据需要同步。有很多原因可以解释为什么即使进度和 db_property('CurrentRedoPos') 存在很大差异也可能导致没有实际数据需要同步。

  1. 当 ML Server 确认上传时,dbmlsync 更新远程的进度值后,dbmlsync 将应用从 ML Server 的下载。 dbmlsync 在下载中应用的操作不会同步回 ML Server,因此整个偏移范围可能只是应用的最后一次下载。当 #hook_dict 表值中的退出代码值为零时,可以通过跟踪 sp_hook_dbmlsync_end 挂钩中的当前日志偏移量来解决此问题。这将告诉您应用下载后数据库的日志偏移量,您现在可以将保存的值与当前日志偏移量进行比较。
  2. 事务日志中的所有操作都可能是对未同步的表的操作。
  3. 事务日志中的所有操作都可以回滚。

我的解决方案并不理想。自己跟踪同步表的更改是最好的解决方案,但我认为我可以提供一种可能满足您需求的替代方案,其优点是您不会对同步表上执行的每个操作触发额外的操作。

There's nothing automatic to tell you that there is data to synchronize. In addition to Ben's suggestion, another idea would be to query the SYS.SYSSYNC table at the remote database to get an idea of whether there might be changes. The following statement returns a result set that shows a simple status of your last synchronization :

select ss.site_name, sp.publication_name, ss.log_sent,ss.progress 
from sys.syssync ss, sys.syspublication sp 
where ss.publication_id = sp.publication_id
and ss.publication_id is not null 
and ss.site_name is not null

If progress < log_sent, then the status of the last synchronization is unknown. The last upload may or may not have been applied at the consolidated, because the upload was sent, but no response was received from the MobiLink server. In this case, suggesting a synch isn't a bad idea.

If progress = log_sent, then the last synch was successful. Knowing this, you could check the value of db_property('CurrentRedoPos'), which will return the current log offset of the remote database. If this value is significantly higher than the progress value, there have been many operations applied to the database since the last synchronization, so there's a good chance that there is data to synchronize. There are lots of reasons why even a large difference in progress and db_property('CurrentRedoPos') could result in no actual data needing synchronization.

  1. The download from the ML Server is applied by dbmlsync after the progress value at the remote is updated by dbmlsync when the upload is confirmed by the ML Server. Operations applied in the download by dbmlsync are not synchronized back to the ML Server, so the entire offset range could just be the last download that was applied. This could be worked around by tracking the current log offset in the sp_hook_dbmlsync_end hook when the exit code value in the #hook_dict table value is zero. This would tell you the log offset of the database after the download was applied, and you could now compare the saved value with the current log offset.
  2. All the operations in the transaction log could be operations on tables that are not synchronized.
  3. All the operations in the transaction log could have been rolled back.

My solution is not ideal. Tracking the changes to synchronized tables yourself is the best solution, but I thought I could offer an alternative that might be OK for your needs, with the advantage that you are not triggering an extra action on every operation performed on a synchronized table.

阪姬 2024-08-21 04:14:02

移动数据库不会跟踪上次同步的时间,MobiLink 服务器将所有这些信息保留在统一数据库的 MobiLink 表中。

由于同步仅传输必要的信息,因此您只需启动同步即可。如果没有任何内容需要同步,那么您的应用程序将使用很少的数据。

附带说明一下,SQL Anywhere 有自己的 SO 克隆,由 Sybase 工程师监控。如果有人确切知道的话,那就是他们了。

The mobile database doesn't keep track of when the last sync was, the MobiLink server keeps all of that information in the MobiLink tables of the consolidated database.

Since synchronization only transfers necessary information, you could simply initiate a sync. If there's nothing to sync, then very little data will be used by your application.

As a side note, SQL Anywhere has its own SO clone which is monitored by Sybase engineers. If anyone knows for sure, it'll be them.

第几種人 2024-08-21 04:14:02

从 SQL Anywhere 17 开始,SAP PM 映射到包含 TTRANSACTION_UPLOAD 表的本地 Sybase 数据库,因此要确定是否需要同步,我们只需查询该表以查看它是否有任何需要同步到 HANA 的记录整合数据库。

As of SQL Anywhere 17, SAP PM maps to a local Sybase database that contains a TTRANSACTION_UPLOAD table, so to determine if a synchronization is necessary we simply query this table to see if it has any records that need to be sync'd to the HANA consolidation database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文