Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> DBMS_RANDOM package with negative random numbers ??
Hi all,
has anybody experience with the package DBMS_RANDOM
on Windows NT?
Is my perspective wrong if I say:
"Random numbers have to be positiv!"
I have worked with C, Perl, JavaScript, (Visual) Basic
and in all those languages (or in their libary functions)
random numbers are positiv!
So why not in PL/SQL?
Is there a type cast, that I missed?
Is the problem related to the int representation on WinNT?
Or is it due to my rather old Oracle Version 8.0.4?
I included the following code snippet, that makes use of the dbms_random package.
DECLARE
v_nInt BINARY_INTEGER;
v_nRandom number(20);
BEGIN
Select hsecs Into v_nRandom From v$timer;
dbms_output.put_line( v_nRandom ); dbms_random.initialize(v_nRandom); FOR i IN 1..10 LOOP v_nInt := dbms_random.random(); v_nRandom := v_nInt;
-- dbms_output.put_line( v_nInt );
dbms_output.put_line( v_nRandom );
288330377
-1420311009
-1168730824
1601612920
-408652530
635338897
1636768007
-618724749
-1679183912
-816529764
1734396077
PL/SQL procedure successfully completed.
As you see I also tried to output the BINARY_INTEGER directly with exactly the same results as with the NUMBER variable. Not sure if dbms_output.put_line() is the right way to look at a variable's value, as it probably does some type conversion internally.
Any comment is appreciated.
Thanks, Rolf.
Received on Fri May 31 2002 - 11:33:38 CDT