Home » Developer & Programmer » Forms » Update random rows in a table
Update random rows in a table [message #457499] Mon, 24 May 2010 20:40 Go to next message
h_jitendras
Messages: 36
Registered: October 2006
Member
Hi,
I have this requirement in Oracle FORMS ver 6i where I populate some records in a table in a datablock and display them on the screen. A facility needs to be provided to the end users to select the records randomly by just entering the count of the records in a non-d/b text field. The number entered in the count field will decide how many records are to be selected randomly.

I tried using the query -
UPDATE <table a>
SET <col 1> = <value 1>
WHERE rowid IN (SELECT rowid FROM (SELECT * FROM <table a> ORDER BY DBMS_RANDOM.VALUE)
WHERE <col 2> = <value 2>)
/

which I found on the link http://forums.oracle.com/forums/thread.jspa?threadID=625395
but while compiling, the Form gives a compilation error for the ORDER by clause - i'm sure there's no syntax error in the way I have written it...

Any suggestions?
Re: Update random rows in a table [message #457511 is a reply to message #457499] Tue, 25 May 2010 00:06 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
Forms 6i code line is little older than DB (Check this).
I think you can use SAMPLE instead of this.

By
Vamsi
Re: Update random rows in a table [message #457521 is a reply to message #457511] Tue, 25 May 2010 01:03 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Try to put the UPDATE statement into a stored procedure and then call this procedure from a form.
Re: Update random rows in a table [message #458031 is a reply to message #457521] Wed, 26 May 2010 20:45 Go to previous messageGo to next message
h_jitendras
Messages: 36
Registered: October 2006
Member
Thanks once again littlefoot... i did put this code snippet in a procedure ..a program unit and it worked.
Sometimes with FORMS, it amazes me why the code didnt work as it is and had to be called from a procedure instead?

Thanks all for your suggestions and your help.
Re: Update random rows in a table [message #458044 is a reply to message #458031] Thu, 27 May 2010 00:04 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
it amazes me why the code didnt work as it is

Because Forms' PL/SQL engine is not the same as the database's one. Basically, new features are first implemented on the database level. Forms follows.
Re: Update random rows in a table [message #458171 is a reply to message #458044] Thu, 27 May 2010 12:43 Go to previous message
h_jitendras
Messages: 36
Registered: October 2006
Member
Thanks for the clarification
Previous Topic: List Item INDEX
Next Topic: Make a field as mandatory at current record level
Goto Forum:
  


Current Time: Thu Sep 19 18:01:46 CDT 2024