How about this:
<!--- in the application.cfm --->
<cflock scope="application" timeout="20" type="exclusive">
<cfquery name="APPLICATION.get_all_ids" datasource="#REQUEST.dsn#">
SELECT column1, column2, column3
FROM Table
</cfquery>
</cflock>
<!--- on the display page --->
<cfoutput>
<cflock scope="application" timeout="10" type="readonly">
#APPLICATION.get_all_ids[RandRange(1,
APPLICATION.get_all_ids.recordcount)]#
</cflock>
</cfoutput>
Why requery when you've already gotten all the records?
Sharon
At 01:05 PM 8/4/2000 -0700, Dan Haley wrote:
>You can probably do this in many ways, but the trick will be to keep the
>amount of calls to the database to a minimum. With that in mind, here's a
>first try . . .
>
><!--- all rows in oracle tables have a 'rowid' field --->
><cfquery name="get_all_ids" . . . >
>select rowid
>from sometable
></cfquery>
>
><!--- now choose the random numbers between 1 and get_all_ids.recordcount
>--->
>.... umm, you can look this up . . .
>
><!--- now use the random numbers to get your three records --->
><cfquery name="get_rand_records" . . . >
>select field1, field2
>from sometable
>where rowid in ('#get_all_ids.rowid[randomnumber1]#',
>'#get_all_ids.rowid[randomnumber2]#',
> '#get_all_ids.rowid[randomnumber3]#')
></cfquery>
>
>Dan
>
>-----Original Message-----
>From: Brandon Behrens [mailto:[EMAIL PROTECTED]]
>Sent: Friday, August 04, 2000 10:10 AM
>To: [EMAIL PROTECTED]
>Subject: OT: Selecting records at random in Oracle
>
>
>Hello all,
>
>I don't know if this is possible but I was wondering if there was a way to
>tell oracle (using cold fusion) that I wanted 3 records, but I didn't care
>which ones they were. I guess a good analogy would be you load up a page
>and you want to display a banner ad, but you don't care which banner ad you
>display. Any help would be appreciated.
>
>Thanks in advance,
>
>Brandon Behrens
>
>Brandon Behrens
>The Internet Design Firm
>512.451.5225
>[EMAIL PROTECTED]
>http://www.theidf.com
>
>
>
>----------------------------------------------------------------------------
>--
>Archives: http://www.mail-archive.com/[email protected]/
>To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
>send a message to [EMAIL PROTECTED] with 'unsubscribe' in
>the body.
>---------------------------------------------------------------------------
---
>Archives: http://www.mail-archive.com/[email protected]/
>To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
>
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.