Hi Rashid,

(Yet) another option is to try something like this:

define function guid() as xs:unsignedLong {
    xdmp:hash64(concat(
        xs:string(xdmp:host()), 
        xs:string(current-dateTime()), 
        xs:string(xdmp:request-key())))
}

-Matt

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ryan Grimm
Sent: Monday, May 14, 2007 5:05 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] About hash map function

Hi Rashid,

In XQuery, the current-dateTime() will always return the same value 
during the execution of the query.  To see this try executing this
query:

current-dateTime(),
xdmp:sleep(5000),
current-dateTime()

You'll see that result of current-dateTime() is the same for both calls 
even though there was a sleep in there for 5 seconds.

If you're looking for a unique value for some id's you could probably 
use xdmp:random() to generate an unsigned 64bit integer.  While there is

a small possibility of xdmp:random() returning the same value twice, the

  same potential problem exists for xdmp:hash64().

Hope that helps.

--Ryan


Nizamuddin, Rashid wrote:
> Could anybody please tell me why I am not getting a unique value when
I 
> execute this loop
> 
> *let $cnt := 1 to 5*
> 
> *for $c in $cnt*
> 
> *return *
> 
> *    let $str := xdmp:hash64(string(current-dateTime()))*
> 
> *    return $str*
> 
> * *
> 
> *for each iteration I get the same value. I need to get a unique value

> to insert in some ids elements.*
> 
> * *
> 
> *Any help will be appreciated*
> 
> * *
> 
> *Rashid*
> 
> * *
> 
> 
>
------------------------------------------------------------------------
> 
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to