trgr:trigger-set-event( $trigger-name as xs:string, $event as element() ) as empty-sequence()
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.
|
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: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.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.