This is an old revision of the document!


Omnidex SQL Function: $RANDOM

Description

Returns a pseudo-random number. The term “pseudo-random” is used since randomization is done using the POSIX rand and srand functions. While these routines do provide satisfactory randomization for most applications, the numbers generated are not entirely random.

If seed is specified, it is used to start the random number generator. Note that only a single $random stream can be used in the process. If there are multiple $random functions in a select, only the first seed is used. Seed must be a literal.

This function returns an INTEGER datatype.

Syntax

$RANDOM( numeric_expression [, seed] )

numeric_expression

Required. Any expression that returns a numeric expression.

seed

Optional. An integer n is an integer indicating the number of digits to the right of the decimal. The default is 0.

Example

Example 1: $RANDOM without a seed

> select $random rnd from $omnidex;

RND
-----------
 1210253353

Example 2: $RANDOM with a seed

> select $random(12345) rnd from $omnidex;

RND
-----------
 1255939488

Additional Resources

See also:

DRAFT

Omnidex SQL Function: $RANDOM

Description

Returns a pseudo-random number. The term “pseudo-random” is used as randomization is done using the Posix rand and srand functions. While these routines do provide satisfactory randomization for most applications, the numbers generated are not entirely random.

If seed is specified, it is used to start the random number generator. Note that only a single $random stream can be used in the process. If there are multiple $random functions in a select, only the first seed is used. Seed must be a literal. The return value is INTEGER length 4.

Syntax

$RANDOM[(seed)]

(seed)

Optional. Seed must be a literal.

Example

Example 1

$RANDOM(9)

68 6151 …

 
Back to top
dev/sql/functions/random.1278707151.txt.gz · Last modified: 2016/06/28 22:38 (external edit)