Hi,

I'm setting up some triggers to be able to see when a database has been 
updated/changed, so I can tell whether or not it is necessary to do a 
new backup.

I've created 3 triggers, for modify, create and delete. What I would 
like to do is for the triggers to be disabled the first time any of them 
is fired, so that I by checking for the triggers status (enabled or 
disabled) can see if the database has changed. But how do I disable 
triggers in code launched by triggers? I don't have any problems 
disabling and enabling them from XQuery scripts on the http server 
connected with the database, but it doesn't work when the script is in 
the database, and is launched/evaluated from there.

We use a single database setup ("Main") with a trigger database 
("Triggers"). The triggers look like this:
Trigger When Status Scope Event Module
createTrigger post-commit enabled /data/ : 1 Document : create Main: 
/modules/disable-triggers.xqy
deleteTrigger post-commit enabled /data/ : 1 Document : delete Main: 
/modules/disable-triggers.xqy
modifyTrigger post-commit enabled /data/ : 1 Document : modify Main: 
/modules/disable-triggers.xqy

/modules/disable-triggers.xqy in the Main database looks like this:
xquery version "0.9-ml"
xdmp:login("admin",()),
let $query := '
xquery version "0.9-ml"
import module namespace trgr="http://marklogic.com/xdmp/triggers"; at 
"/MarkLogic/triggers.xqy"
xdmp:login("admin",()),
trgr:trigger-disable("modifyTrigger"),
trgr:trigger-disable("deleteTrigger"),
trgr:trigger-disable("createTrigger")
'
return (xdmp:eval($query, (), <options xmlns="xdmp:eval">
     <database>{xdmp:database("Triggers")}</database></options>))

And the ErrorLog produces this:
2010-10-11 13:39:48.542 Notice: TaskServer: SEC-PRIV: 
xdmp:eval("&#10;xquery version &quot;0.9-ml&quot;&#10;import module 
namespa...", (), <options xmlns="x
dmp:eval"><database>8834233087481101973</database></options>) -- Need 
privilege: http://marklogic.com/xdmp/privileges/xdmp-eval
2010-10-11 13:39:48.542 Notice: TaskServer: in /disable-triggers.xqy, on 
line 15 [0.9-ml]
2010-10-11 13:39:48.542 Notice: TaskServer: $query = "&#10;xquery 
version &quot;0.9-ml&quot;&#10;import module namespa..."


So it seems the problem have something to do the permissions, but since 
I run the scripts as admin I don't understand why that is a problem.
I hope someone can help me!

Best regards,
Tomas
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to