Reputation: 67
I tried using xdmp:random(999999)
but it sometimes generates a 5 digit value and sometimes a 6 digit value - Is there any way of getting the every time unique 6 digit value?
Upvotes: 1
Views: 153
Reputation: 7132
If leading zeroes don’t work, make sure your base value is 100,000 and go up to 999,999.
xdmp:random(899999) + 100000
Upvotes: 2
Reputation: 20414
Simplest is to pad with zeros using fn:format-number
:
format-number(xdmp:random(999999), '000000')
Alternatively, you could also look at sem:uuid-string
, which gives better random results with a fixed string-length.
HTH!
Upvotes: 4