MarkLogic Server 11.0 Product Documentation
trgr:trigger-set-event

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

Summary

Assigns a triggering event to the named trigger.

Parameters
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.

Example

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:trigger-set-event(
  "myTrigger", 
  trgr:trigger-data-event(
    trgr:directory-scope("/myDir/", "1"),
    trgr:document-content("create"),
    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.
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy