× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You will almost surely not want to reseed every time in that manner. That could just as well be replaced by microseconds to get a /random/ value. Investigate a solution that has the original non-seeded RAND() giving an expected pseudo-random number versus the same value every time. Release was not mentioned... Note that on V6R1 a PTF was required [maybe a PTF is required to the GA code; for sure pre-GA] which corrects a problem [at least somewhat] similar to the problem described here.

Regards, Chuck

Michael_Schutte@xxxxxxxxxxxx wrote:
I am able to solve my issue by inserting an integer value in the Rand
function.

I converted the current time into a 10I 0 field, then executed.

CurrentTime = %Dec(%Time():*ISO);
Exec SQL Select Dec(Rand(:CurrentTime)*10000000000,10,0)
Into :RandomNumber
From SYSIBM/SYSDUMMY1;

But I question why....????

Michael Schutte/Bob Evans wrote on 05/05/2008 10:53:34 AM:

I know that there's been a big discussion about this before... but I
have an issue that I couldn't find in the archives.

If I run this statement interactively (in STRSQL). I get a
different value everytime...
select dec((rand()* 10000000000),10,0) from sysibm/sysdummy1

But when I put it in the SQLRPGLE program (which so happens to be a
DEV2 web program), I get the same value.
select dec((rand()* 10000000000),10,0) into :RandomNumber from
sysibm/sysdummy1

RandomNumber always equals 5138706625

If I put a number in the Rand Function, Rand(somenumber). I get a
different value than above but it doesn't change on repeated calls.

The activation group is *NEW and the Rand function is non-
deterministic. So I don't follow why I'm getting the same value.

I've even tried doing Values(...) into :RandomNumber;

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.