|
|
|
|
|
|
|
|
|
|
|
Re: How To Use random in forms [message #440596 is a reply to message #440573] |
Tue, 26 January 2010 00:53 |
|
Littlefoot
Messages: 21823 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 likeSQL> 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 #440606 is a reply to message #440604] |
Tue, 26 January 2010 02:10 |
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.
|
|
|
|