The Random Number Mask

 

The Random Number mask will generate random number for all numeric data types: integer, decimal and floating point. It can even generate random numbers for text fields.

The Random Number mask panel is shown below:
  

  

Minimum
  

This specifies the lower limit of the random number range. It can either be a number relative to the original number (as a percentage or explicit number), or an absolute number independent of the original data value.

The screen capture above shows that the lower limit of the random number range shall be the original number minus 25 percent.

Lower Limit

This specifies the minimum value that DataVeil shall generate (the lower range boundary.) If this field is left blank then DataVeil shall assume the smallest value capable of being stored in the data type. For example, DataVeil would assume -32768 if the masked Column was an SQL Server SMALLINT type. If the masked Column is a non-numeric type (i.e. a numeric string) then the minimum value assumed shall be the smallest negative floating point value available on the DBMS.
  

If the original number is NULL and the 'Original number and..' option is selected then NULL shall be returned.

If the original number is NULL and the 'Absolute number' option is selected for both Minimum and Maximum then a random number shall be generated.

 

Maximum
  

This specifies the upper limit of the random number range. It can either be a number relative to the original number (as a percentage or explicit number), or an absolute number independent of the original data value.

The screen capture above shows that the upper limit of the random number range shall be the original number plus 25 percent.

Upper Limit

This specifies the maximum value that DataVeil shall generate (the upper range boundary.) If this field is left blank then DataVeil shall assume the largest value capable of being stored in the data type. For example, DataVeil would assume 32767 if the masked Column was an SQL Server SMALLINT type. If the masked Column is a non-numeric type (i.e. a numeric string) then the maximum value assumed shall be the largest positive floating point value available on the DBMS.
  

If the original number is NULL and the 'Original number and..' option is selected then NULL shall be returned.

If the original number is NULL and the 'Absolute number' option is selected for both Minimum and Maximum then a random number shall be generated.

 

Scale

The Scale panel shall be enabled for data types that are capable of storing a fractional part and text data types. Otherwise, the Scale panel shall be disabled.

This setting is useful to ensure that numbers with a meaningful precision are generated. For example, in SQL Server the MONEY type is actually a DECIMAL with a scale of 4. Therefore, if you wanted to generate random amounts down to the cents level then you should specify '2' in the Scale digits field. If you do not, then the default scale of 4 would be used which could result in numbers such as $125.7289 which may not be desirable for your application.

If the data type is an exact numeric data type that is capable of supporting a decimal point (such as NUMBER in Oracle, or NUMERIC in SQL Server) but is defined with a scale of 0 on the DBMS, then DataVeil shall treat it as an integer and the Scale panel shall not be enabled.

Example: The panel below shows that we wish to randomize amounts by +/- 15% of the original amount, but not lower than 19.95 and not greater than 249.95. We also want to ensure that there are only 2 significant digits after the decimal point.
  

 

Use on String Data Types
  

The Random Number mask can be used on string data types (such as VARCHAR). Of course, you would do this only where it makes sense for your requirements, i.e. where the field is expected to contain a textual representation of a number.

When you create a Random Number mask on a string data type (such as CHAR, VARCHAR, NCHAR and NVARCHAR) then the panel "For string values that cannot be converted to a number..." shall be enabled.

Note: This panel is supported only for SQL Server 2012 or later, and Oracle 10g or later. i.e. This panel shall be disabled for SQL Server 2008 or earlier.

This panel enables you to define what the masking outcome should be for original string values encountered that are not NULL and do not represent valid numbers. In this context, a 'valid' number is a string that can be converted to a floating point number using the native cast operations on the DBMS. For example "$12.95" is an invalid number because CAST('$12.95' AS NUMERIC) would fail because it contains a '$' character.

Therefore, the valid characters for string values are only digits, decimal point ('.' or ','), '+', '-', 'e' and 'E' characters.

The available options for handling original string values that cannot be converted to numbers are:
  

Report error

A error message shall be logged to indicate that a string value that cannot be converted to a number has been found and the masking run shall be terminated. This is the default option.
  

Replace with string value

All original string values that cannot be converted to a number shall be replaced with this user-specified string value.

Note: Do not surround the string value with quotes. All characters in this field are significant including any leading and trailing spaces. If you need to embed a single quote as part of the string value then you should escape it with another single quote. For example, to specify the value 0'12 you should enter 0''12 in the text field.

Note: Unicode strings are handled automatically. i.e. Do not prepend N' to string values that are assigned to unicode data types such as NVARCHAR.
  

Replace with NULL

All original non-NULL string values that cannot be converted to a number shall be replaced with NULLs.

If the original value is a NULL then see the description below for how these are handled.
  

Preserve

All original string values that cannot be converted to a number shall be preserved.

Handling of NULL original values
  

The Random Number mask shall always preserve NULLs if deterministic mode is used.

NULLs shall also be preserved if either the Minimum or Maximum specifies the 'Original number and' option regardless of the determinism setting.

If you want to ensure that NULLs are preserved under any other circumstance then select the Preserve Nulls column option.