Home » Developer & Programmer » Forms » How To Use random in forms (oracle forms)
icon11.gif  How To Use random in forms [message #440470] Mon, 25 January 2010 02:33 Go to next message
wkloveforms
Messages: 14
Registered: January 2010
Junior Member
Hello!

How To Use random in forms~

xxx := DBMS_RANDOM.VALUE --how to use it
Re: How To Use random in forms [message #440485 is a reply to message #440470] Mon, 25 January 2010 03:11 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I guess that you tried to use it exactly like that: xxx := DBMS_RANDOM.VALUE, but didn't work. So, you could try to create a stored function which will return a random value, and then call this function from the form.
Re: How To Use random in forms [message #440486 is a reply to message #440470] Mon, 25 January 2010 03:11 Go to previous messageGo to next message
tamzidulamin
Messages: 132
Registered: October 2009
Location: Dhaka
Senior Member
:block.item:= round(dbms_random.value (Min_Value,max_value));
For Ex:
:block.item:= round(dbms_random.value (1, 15));


Tamzid.
Re: How To Use random in forms [message #440572 is a reply to message #440470] Mon, 25 January 2010 18:10 Go to previous messageGo to next message
wklovesy
Messages: 1
Registered: January 2010
Junior Member
Thanks for reply.....
i have to try it again
Re: How To Use random in forms [message #440573 is a reply to message #440470] Mon, 25 January 2010 19:28 Go to previous messageGo to next message
wkloveforms
Messages: 14
Registered: January 2010
Junior Member
need help

FUNCTION F_RANDOM
RETURN NUMBER IS
  V_RANDOM NUMBER;
BEGIN
  V_RANDOM := round(dbms_random.value(1, 15));
  return V_RANDOM;
END;


ERROR201 'dbms_random.value' must be declared
Re: How To Use random in forms [message #440577 is a reply to message #440573] Mon, 25 January 2010 22:02 Go to previous messageGo to next message
tamzidulamin
Messages: 132
Registered: October 2009
Location: Dhaka
Senior Member
Dear,

please find the attachment...

Tamzid.
Re: How To Use random in forms [message #440580 is a reply to message #440470] Mon, 25 January 2010 22:37 Go to previous messageGo to next message
wkloveforms
Messages: 14
Registered: January 2010
Junior Member
Thanks..

ERROR 201 :'dbms_random.value' must be declared


it is forms 6i
without dbms_random package?

Re: How To Use random in forms [message #440584 is a reply to message #440470] Mon, 25 January 2010 22:47 Go to previous messageGo to next message
tamzidulamin
Messages: 132
Registered: October 2009
Location: Dhaka
Senior Member
which version of Oracle DevSuite u used?
Re: How To Use random in forms [message #440587 is a reply to message #440470] Mon, 25 January 2010 23:11 Go to previous messageGo to next message
wkloveforms
Messages: 14
Registered: January 2010
Junior Member
forms 6i patch 16

[Updated on: Mon, 25 January 2010 23:28]

Report message to a moderator

Re: How To Use random in forms [message #440589 is a reply to message #440587] Mon, 25 January 2010 23:45 Go to previous messageGo to next message
tamzidulamin
Messages: 132
Registered: October 2009
Location: Dhaka
Senior Member
Database Version?
Re: How To Use random in forms [message #440593 is a reply to message #440470] Tue, 26 January 2010 00:42 Go to previous messageGo to next message
wkloveforms
Messages: 14
Registered: January 2010
Junior Member
Oracle 9.2.0.7
Re: How To Use random in forms [message #440596 is a reply to message #440573] Tue, 26 January 2010 00:53 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
wkloveforms wrote on Tue, 26 January 2010 02:28

FUNCTION F_RANDOM
RETURN NUMBER IS
...


ERROR201 'dbms_random.value' must be declared


"FUNCTION F_RANDOM" suggests that you created it in form. Did you? If so, you didn't quite understand what I was saying: you need to create a stored function, the one that is in the database, not in a form. You'd do that in SQL*Plus (or any other tool you use to access the database):
SQL> CREATE OR REPLACE FUNCTION F_RANDOM
  2  RETURN NUMBER IS
  3    V_RANDOM NUMBER;
  4  BEGIN
  5    V_RANDOM := round(dbms_random.value(1, 15));
  6    return V_RANDOM;
  7  END;
  8  /

Function created.

SQL> select f_random from dual;

  F_RANDOM
----------
        12

SQL>

So you'd, basically, call this function in your PL/SQL code; something like
SQL> declare
  2    l_random_val number;
  3  begin
  4    l_random_val := f_random;
  5
  6    dbms_output.put_line('Random value = ' || l_random_val);
  7  end;
  8  /
Random value = 8

PL/SQL procedure successfully completed.
Of course, Forms don't use DBMS_OUTPUT package so you'd do *something* with that value (whatever you plan to do).
Re: How To Use random in forms [message #440604 is a reply to message #440470] Tue, 26 January 2010 01:30 Go to previous messageGo to next message
wkloveforms
Messages: 14
Registered: January 2010
Junior Member
thanks!!!!! Surprised

call the db function..

dbms_random.value must be uesd in the database.I originally thought that it can be used in Forms.

And,I know english a little.. Embarassed
Re: How To Use random in forms [message #440606 is a reply to message #440604] Tue, 26 January 2010 02:10 Go to previous messageGo to next message
tamzidulamin
Messages: 132
Registered: October 2009
Location: Dhaka
Senior Member
Hi,

dbms_random.value must be uesd in the database.I originally thought that it can be used in Forms.


dbms_random.value package must be use in the Form6i or 10g version.

The Following Code is Written in WHEN-BUTTON-PRESSED
trigger is successfully work.
Begin	
:CONTROL.RANDOM_NUMBER:= round(dbms_random.value (1, 15));
End;


I think u have face another problem.

Regards,

Tamzidul Amin.



Re: How To Use random in forms [message #440608 is a reply to message #440470] Tue, 26 January 2010 02:31 Go to previous message
wkloveforms
Messages: 14
Registered: January 2010
Junior Member
Dear !! Tamzidul Amin !!

OK!Thanks!

Embarassed Must Connect The DB!

[Updated on: Tue, 26 January 2010 03:01]

Report message to a moderator

Previous Topic: Frm-9999
Next Topic: Calling reports from forms10G
Goto Forum:
  


Current Time: Fri Sep 20 12:33:25 CDT 2024