uniqness insertion in native xml database

五迷三道 提交于 2020-01-24 13:00:08

问题


I am developing a project based on XML. I use the Sedna database to store my collection (which contains XML files, and their XSD schema files).

I define the primary/unique keys in those schemes, but till now I can insert duplicate values (via XQuery update insert command) into primary key field.


回答1:


To guarantee uniqueness constraint you should create BEFORE INSERT FOR EACH NODE trigger on proper path. In the trigger action the $NEW transitive variable can be used to fetch the new key and check if it already exists in the document (see examples in the manual). To raise error fn:error function can be used.

Take the following note regarding triggers:

  1. "It is prohibited to use prolog in statements of the trigger action" — Sedna Programmer's Guide, XQuery Triggers.

  2. See also bug 51 (although, already closed).



来源:https://stackoverflow.com/questions/41141317/uniqness-insertion-in-native-xml-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!