RndStr Random Type (alphanumeric values)

Action

Declares a random variable of type RndStr. With each access, such a variable contains a random string value. The characters of the string and the length of the string are generated randomly following a uniform distribution.

Syntax

RndStr( s, l..u ): string;

Return value

string

Parameter Description
s

Pattern string - optional (string)

The pattern string defines the characters to be used in the random string. Each character in the pattern string has the same probability of being chosen. If the pattern string is omitted, the standard pattern string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" is used.

l Minimum length of random string (number)
u

Maximum length of random string (number)

Condition: l <= u

Example

dclrand
  rEvent1, rEvent2 : RndBin(0.25);
  rTime1 : RndExpF(5.5);
  rTime2 : RndUniF(0.5..12.5);
  rCube  : RndUniN(1..6);
  rPrice : RndUniN(10..2000);
  rArtNo : RndExpN(1..10000: 100.0);
  rACat  : RndStr("AABBCCDDEEFF0123456789", 3..4);
  rName  : RndStr(10..40);

dclsql
  InsArticle:
    INSERT INTO article (category, name)
    VALUES (:rACat, :rName);

The random variable rACat is used in a SQL command to generate random values for the database field category. The generated values are alphanumeric values with a length of 3 or 4 characters. The pattern string consists of the digits 0 to 9 and the characters A to F. The probability of the characters A to F is twice the probability of the digits. The random variable rName is used in a SQL command to generate random values for the database field name. The generated values are alphanumeric values with a length of 10 to 40 characters. The standard pattern string (A to Z) is used.

Sample scripts

OraSample.bdf