Oh by the way, one could ofcourse specify the database itself as it triggers 
database, but that might be too confusing for some.. :*)

Kind regards,
Geert

> -----Original Message-----
> From: Geert Josten 
> Sent: maandag 22 maart 2010 20:14
> To: 'General Mark Logic Developer Discussion'
> Subject: RE: [MarkLogic Dev General] Create trigger from 
> XQuery, not see it in the console
> 
> Right,
> 
> So we were right about all except that the eval or invoke 
> should be run against the database that actually stores the 
> triggers, not the documents database, as is stated on top of 
> Triggers documentation:
> 
> http://developer.marklogic.com/pubs/4.1/apidocs/Triggers.html,
> 
> "The trigger functions should all be run against the triggers 
> database for the database in which the content is stored."
> 
> Something you don't need to remember if you use the CPF.. ;-)
> 
> Thank Danny!
> Geert
> 
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Danny 
> > Sokolsky
> > Sent: maandag 22 maart 2010 19:36
> > To: General Mark Logic Developer Discussion
> > Subject: RE: [MarkLogic Dev General] Create trigger from 
> XQuery, not 
> > see it in the console
> > 
> > It sounds like everyone is saying correct things, but here is a 
> > summary of how this works:
> > 
> > The trigger API is designed to be run against a database 
> that is being 
> > used as a triggers database (that is, a database that some database 
> > points to as its triggers database).  Note that this may or 
> may not be 
> > the database named "Triggers" (as that is just a database). 
>  Remember, 
> > the trigger API simple creates XML documents in a database, and the 
> > system then knows how to use those as triggers (the 
> security API works 
> > similarly, but with the security database).
> > 
> > The xdmp:eval approach (could be used with xdmp:invoke too) 
> where you 
> > send a <database> option is a good approach if you are 
> scripting this 
> > process.  The built-in
> > xdmp:triggers-database() is useful here, because then you 
> can run it 
> > against the content database and it will eval into the 
> database that 
> > is configured as the triggers db.
> > 
> > The triggers status page in the Admin Interface shows triggers that 
> > are created in the triggers database for the specified 
> database, not 
> > triggers that exist in the content database (unless you have the 
> > content database specified as the triggers database).
> > 
> > As a practical matter, if you are using CQ to create these 
> triggers, 
> > make sure to set the database drop-list to the db you have 
> specified 
> > as your triggers db.
> > 
> > Clear as mud?
> > 
> > -Danny
> > 
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Geert 
> > Josten
> > Sent: Monday, March 22, 2010 11:22 AM
> > To: General Mark Logic Developer Discussion
> > Subject: RE: [MarkLogic Dev General] Create trigger from 
> XQuery, not 
> > see it in the console
> > 
> > Hi Florent,
> > 
> > I think Andrew is right. It is good to be aware how Trigger 
> databases 
> > are referenced. You are executing your query against a specific 
> > AppServer that has a Documents database setting of its own. So just 
> > executing your query will insert the trigger into the Triggers 
> > database assigned to the Documents database that has been 
> associated 
> > with the AppServer you are using. (Still following? :-P)
> > 
> > Using the eval approach described by Andrew helps in so far that it 
> > ensures you will be using the Triggers database associated with the 
> > db-xxx database. But your description below shows that you haven't 
> > associated a Triggers database at all. That will be 
> necessary to see 
> > the triggers on the console, but might also be necessary to 
> create the 
> > trigger itself (not sure though, you seem to get an ID back)..
> > 
> > Kind regards,
> > Geert
> > 
> > >
> > 
> > 
> > drs. G.P.H. (Geert) Josten
> > Consultant
> > 
> > 
> > Daidalos BV
> > Hoekeindsehof 1-4
> > 2665 JZ Bleiswijk
> > 
> > T +31 (0)10 850 1200
> > F +31 (0)10 850 1199
> > 
> > mailto:[email protected]
> > http://www.daidalos.nl/
> > 
> > KvK 27164984
> > 
> > P Please consider the environment before printing this mail.
> > De informatie - verzonden in of met dit e-mailbericht - is 
> afkomstig 
> > van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. 
> > Indien u dit bericht onbedoeld hebt ontvangen, verzoeken 
> wij u het te 
> > verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.
> > 
> > > From: [email protected]
> > > [mailto:[email protected]] On Behalf
> > Of Florent
> > > Georges
> > > Sent: maandag 22 maart 2010 18:31
> > > To: MarkLogic General ML
> > > Subject: [MarkLogic Dev General] Create trigger from
> > XQuery, not see
> > > it in the console
> > >
> > >   Hi,
> > >
> > >   I have a database configured as:
> > >
> > >     Name:        db-xxx
> > >     Security db: Security
> > >     Schema db:   Schemas
> > >     Triggers db: (none)
> > >
> > >   I create a new trigger by using the following code:
> > >
> > >     xquery version "1.0";
> > >     import module namespace tr =
> > "http://marklogic.com/xdmp/triggers";
> > >       at "/MarkLogic/triggers.xqy";
> > >     declare namespace xdmp = "http://marklogic.com/xdmp";;
> > >
> > >     tr:create-trigger(
> > >       'xxx',
> > >       'no description',
> > >       tr:trigger-data-event(
> > >         tr:collection-scope('tmp'),
> > >         tr:document-content('create'),
> > >         tr:pre-commit()
> > >       ),
> > >       tr:trigger-module(xdmp:database('db-xxx'), 'tmp/',
> > 'test.xqy'),
> > >       true(),
> > >       xdmp:default-permissions(),
> > >       false()
> > >     )
> > >
> > >   It runs correctly and returns an integer (the ID of the
> > trigger if I
> > > am right).  So I expected to see the trigger in the 
> console, in the 
> > > tab "Databases/db-xxx/Triggers", but this one is empty.
> > >
> > >   Did I miss anything?  Can I provide more infos?
> > >
> > >   Regards,
> > >
> > > --
> > > Florent Georges
> > > http://www.fgeorges.org/
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > General mailing list
> > > [email protected]
> > > http://xqzone.com/mailman/listinfo/general
> > >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://xqzone.com/mailman/listinfo/general
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://xqzone.com/mailman/listinfo/general
> > _______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to