Example 1: Invoking a Randomizer

Previous Next

This example shows how an external component returns a random number for a lottery. Each customer booking a reservation automatically gets a free lottery number.

The component uses an input parameter to determine between which number and zero a random number must be found. In this example, lottery numbers between 0 and 10000 are returned.

The example uses the Travel Agency case .

To try out this example:

Locate the Samples/Usmath directory on your CD.

Read the README.TXT file for information on installing, running and inspecting the sample component.

Component Name


Component Prog ID




Physical Method


Parameters of RANDOM

In - Long Integer

Return - Long Integer


Add a LOTTERY_NO column based on a regular NUMBER(8) domain



Message: "Lottery no. assigned."

Transition Table: RESERVATION

Fire on Insert: Always

Fire on Delete: Never

Fire on Update: Never

UPDATE    reservation

SET     lottery_no =


   INVOKE usmath.random


   SELECT 10000



Description of functionality:

The randomizer component returns a random integer between 0 and the input parameter.

Code of invoked subprogram:

Public Function Random(maxi As Integer) As Integer


   Random = Int(maxi * Rnd)

End Function