Jim:
I knew I had seen something on this topic. Jonathan Leffler, the informix heavy weight of heavy weights, posted this:
--Jonathan Leffler
-- Simple emulation of SRAND and RAND in SPL
-- Using random number generator suggested by C standard (ISO 9899:1990)
CREATE PROCEDURE sp_setseed(n INTEGER)
DEFINE GLOBAL seed DECIMAL(10) DEFAULT 1;
LET seed = n;
END PROCEDURE;
CREATE PROCEDURE sp_random() RETURNING INTEGER;
DEFINE GLOBAL seed DECIMAL(10) DEFAULT 1;
DEFINE d DECIMAL(20,0);
LET d = (seed * 1103515245) + 12345;
-- MOD function does not handle 20-digit values...
LET seed = d - 4294967296 * TRUNC(d / 4294967296);
RETURN MOD(TRUNC(seed / 65536), 32768);
END PROCEDURE;
Execute it as such:
select sp_random() from systables where tabname = "systables"
Jonathan hangs out at comp.databases.informix. If you have a question, I'll bet he'll help.
I grabbed this from the International Informix User's group webpage:
They have a section on SQL, 4GL, SP, and other tools that's worth checking out.
Regards,
Ed
Schaefer