Random Integer
Goal
Write mask
rule logic to
- generate random integers from an interval defined by
<from>
and<to>
properties
Ano Structure and Examples
- Structure
- Update Example
- Create Example
- Different Format Example
- Huge Number Example
...
mask <column> <rule-name>
format %d
random-integer <from> <to> // Includes from and to
...
table birth_certificate
column integer birth_pregnancy_week
column ...
task ... {
update birth_certificate
...
mask birth_pregnancy_week
format %d
random-integer 25 45
...
}
table birth_certificate
column integer birth_pregnancy_week
column ...
task ... {
create birth_certificate
minimum-rows 50
...
mask birth_pregnancy_week
format %d
random-integer 25 45
...
}
table CUSTOMER
...
column text PHONE size 20
...
...
task ... {
update CUSTOMER
...
mask PHONE <rule-name>
format "+47 %d" // String format of Norwegian phone numbers
random-integer 10001000 99909990
...
}
task ... {
update <table>
...
mask <column>
format "%d%d" // 16 digit number
random-integer 10001000 99909990 // 8 digit number
random-integer 10001000 99909990 // 8 digit number
...
}
<from>
and<to>
values are included in the generated values.- If desired result is differs from integer, simply change the format string.
- For strings, simply format with double quoutes
"%d"
, and the generated integers would become strings.
- For strings, simply format with double quoutes
Limits
random-integer
usesjava.lang.Integer
. Values can thus only be generated from the range[-2147483648, 2147483647]
, i.e., 9-10 digit numbers.
Workaround
- If a larger (positive or negative) value than the allowed range is sought, then use multiple 'random-integer' together, and concatenate them inside a string, as per the example above.