Loading TOC...


   trigger-name as xs:string,
   event as element()
) as empty-sequence()


Assigns a triggering event to the named trigger.

trigger-name The trigger name.
event An event definition. Use trgr:trigger-data-event or trgr:trigger-database-online-event to construct this element.

Usage Notes

A trigger event describes the conditions under which the trigger fires. After calling this function, any previous event associated with the trigger is replaced.

This function must be run in the context of the database containing the trigger to be modified.

If the named trigger does not exist, the exception TRGR-TRIGGERDNE is raised.


xquery version "1.0-ml";
import module namespace trgr="http://marklogic.com/xdmp/triggers" 
   at "/MarkLogic/triggers.xqy";

(: Run in the context of the database containing the trigger :)
    trgr:directory-scope("/myDir/", "1"),
    trgr:post-commit()) )

  => Empty sequence. The trigger "myTrigger" is set to fire 
     whenever a document is created in "/myDir/". The trigger 
     module runs after the creating transaction is committed.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.