triggers - 检索事务中预提交触发器删除的文档

标签 triggers marklogic marklogic-9

我们在文档删除事件上有一个预提交触发器,在与触发器关联的 XQuery 模块中,我们无法检索文档内容。

我们获取文档 URI,但是当我们执行 fn:doc($uri) 时,它不会返回文档内容。

有没有办法在事务中获取已删除文档的内容?

最佳答案

如果您删除文档它将在预提交触发器中不可用

触发器将看到对文档所做的更新。在这种情况下,它已经被删除并且不可用。

Pre-Commit Triggers

The module invoked as the result of a pre-commit trigger is evaluated as part of the same transaction that produced the triggering event. It is evaluated by invoking the module on the same App Server in which the triggering transaction is run. It differs from invoking the module with xdmp:invoke in one way, however; the module invoked by the pre-commit trigger sees the updates made to the triggering document.

Therefore, pre-commit triggers and the modules from which the triggers are invoked execute in a single context; if the trigger fails to complete for some reason (if it throws an exception, for example), then the entire transaction, including the triggering transaction, is rolled back to the point before the transaction began its evaluation.

您还没有描述您想要实现的目标,或者如何执行删除。听起来您确实需要预删除操作,而不是预提交。可能还有其他方法可以达到预期的结果。

例如,您可以考虑使用自定义函数来执行删除。

  • 您可以将逻辑从预提交触发器移至该自定义函数中,以避免完全使用触发器。

  • 或者自定义函数可以执行“软删除”,以便将其标记为已删除且不可用(即调整权限),然后允许预提交触发器执行 xdmp:document-delete() .

关于triggers - 检索事务中预提交触发器删除的文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51535463/

相关文章:

mysql - 创建允许的最大值触发器

qt - PyQT按钮点击名称

java - 使用 Marklogic java API 进行通配符搜索

marklogic - 带有 xsi :noNamespaceSchemaLocation 的片段根上的 XDMP-PARENTLINK 错误

upgrade - 将数据从 MarkLogic 7 上的数据库迁移到 MarkLogic 9 上的数据库

mysql - 触发器从源表和另一个表插入数据

ListBox 项目的 DataTemplate 中 IsSelected 的 WPF 触发器

java - Marklogic Java,指定查询结果的长度

linux - Redhat 7 上的 Marklogic 安装

java - 使用 java 的 marklogic 中的方面