This is correct functionality. Within a single XQuery statement fn:current-dateTime will return the same value. This is defined in the W3C XQuery specifications. The specifications do not cover the concept of multiple 'statements' or 'transactions' or spawn/eval/invoke etc -- those are higher level vendor specific concepts. The behavior you are seeing is exactly what should be expected. Within any 'statement' fn:current-dateTime() is guaranteed to be the same; In different statements it may be different (depending on the precision of the time format and how fast the statements are executed.)
A minimal case to try is this: ----- Single Xquery Statement. fn:current-dateTime(), xdmp:sleep(1000), fn:current-dateTime() ----------------->>> This will produce the same results for both vs -------- Multiple XQuery Statements (note ";" vs "," ) fn:current-dateTime(); xdmp:sleep(1000); fn:current-dateTime(); -----> The second time will be approx. 1 second greater than the first. From: [email protected] [mailto:[email protected]] On Behalf Of sweet frd Sent: Thursday, January 05, 2017 2:00 AM To: MarkLogic Developer Discussion <[email protected]> Subject: Re: [MarkLogic Dev General] fn:current-dateTime() Hi All, Please find the below code snippet in which i have created an invoke and module xquery with same fn:current-dateTime() logging and returning result. As a result I can able to see the timestamp is different : 1. when an other xquery is called using invoke 2. when an other xquery is called using spawn 3. when using spawn function for both local and other module xquery function Sample : import module namespace check = "http://marklogic.com/check" at "/a/common/check_now.xqy"; declare function local:dateTime(){ ( fn:current-dateTime(), xdmp:log(("local fun",fn:current-dateTime())) ) }; let $check := fn:current-dateTime() let $time := cts:uri-match("*") let $time := cts:search(doc(),()) let $check1 := xdmp:invoke("/a/common/now.xqy") let $check11 := xdmp:spawn("/a/common/now.xqy") let $check2 := fn:current-dateTime() let $check3 := local:dateTime() let $check4 := check:dateTime() let $check5 := xdmp:spawn-function(function(){local:dateTime()}) let $check6 := xdmp:spawn-function(function(){check:dateTime()}) return ("Result",$check,"aaa",$check1,"aaa11",$check11,"bbb",$check2,"ccc",$check3,"ddd",$check4,"spawn eee",$check5, "fff",$check6) Verify the result and marklogic logs.. Regards, N. Sumathi. On Thu, Nov 17, 2016 at 6:53 AM, Florent Georges <[email protected]<mailto:[email protected]>> wrote: Hi, The current date and time is the same through the evaluation of the entire query. So if "submodule.xay" is a library module, imported in the main module, that will give you the exact same value. If it is not a library module, and you invoke, spawn, schedule a task, eval or anything else, it depends on that "anything else"... Regards, -- Florent Georges http://fgeorges.org/ http://h2o.consulting/ - New website! On 17 November 2016 at 12:46, sweet frd wrote: > Hi All, > > I have a module somemodule.xqy which has the following line for logic > > fn:current-dateTime() > > > Will there be a difference in output for the below scenarios > > (a) Invoke the above xquery (somemodule.xqy) in main module > > (b) Directly invoke the function fn:current-dateTime() in the main module > > > Regards, > N. Sumathi. > > _______________________________________________ > General mailing list > [email protected]<mailto:[email protected]> > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected]<mailto:[email protected]> Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
