有什么方法可以模拟 SQl Server Compact 3.5 中的 OUTPUT 子句吗?
我正在实施一个电子邮件队列系统。基本思想是将电子邮件存储在 sql ce Db 中,然后通过 Windows 服务读取它们并发送它们。
假设数据库中有 200 行,我需要首先获取 10 条记录,因此我需要 OUTPUT 子句,以便我可以运行类似的操作(
UPDATE MAILQUEUE Set STATUS='Fetched' where QueueID in (select top(10) QueueID from MailQueue where Status='Queued' order by QueueID asc)
**OUTPUT** deleted.*
如果不可能),我还可以考虑从数据库中永久删除这些行并进行处理并在发生故障时将它们存储在 FailQueue 表中。在这种情况下可以使用 SqlCeTransaction 类来完成选择和删除吗???
如果有更好的方法来实现,请告知。
感谢大家
I am implementing a Email Queue system. the basic idea is to store emails in the sql ce Db and then read them through a Windows Service and send them.
Assuming that there are 200 rows in the DB i need to fetch 10 records first and so i needed the OUTPUT clause so that i could run something like this
UPDATE MAILQUEUE Set STATUS='Fetched' where QueueID in (select top(10) QueueID from MailQueue where Status='Queued' order by QueueID asc)
**OUTPUT** deleted.*
if this is not possible i can also think of removing the rows permanently from the DB and processing them and incase of failure store them in a FailQueue table. In this case can Select and Delete be done using the SqlCeTransaction class????
If there is a better way to implement this please advise.
Thanking all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在单个 SqlCeTransaction 中执行 SELECT 和 UPDATE 就可以解决问题。
Performing your SELECT and UPDATE in a single SqlCeTransaction would do the trick.