Custom return order.

Sims, John (CDC/CCHP/NCBDDD) (CTR) ayu8 at cdc.gov
Mon Jul 24 09:27:37 CDT 2006


> -----Original Message-----
> From: valentina-bounces at lists.macserve.net 
> [mailto:valentina-bounces at lists.macserve.net] On Behalf Of 
> Ruslan Zasukhin
> Sent: Sunday, July 23, 2006 5:20 PM
> To: valentina at lists.macserve.net
> Subject: Re: Custom return order.
> 
> On 7/23/06 11:09 PM, "Justin Drury" 
> <justin at crunch-recording.com> wrote:
> 
> Hi Justin,
> 
> > Wondering if there is a provision in Valentina to return 
> results back 
> > using a vcursor in a custom/random order.  I've tried getting the 
> > recID's for a result set and then randomizing their 
> position and then 
> > doing a select where RecID=xxx or RecID=yyy, but the results always 
> > come back in the original order.  Ideally a select * from 
> xxx order by 
> > rand(RecID) would be ideal... : )
> 
> Well, I have never seen such "feature" in any DBMS.
> 
> I think you can simulate what you want using ArraySet.
> 
> 
> --
> Best regards,
> 
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc


Hi Justin,

The only way I have ever been able to accomplish what you are asking
(without creating a custom wrapper class) is to do the following:

1) Add a field to your table called DisplayOrder
2) Select your records (all you really need is the RecIDs)
3) Randomize your RecIDs and put them into an Array (in their random
order)
4) Update your table setting the DisplayOrder field equal to the array
index for each RecID
5) Select the records from your table with ORDER BY DisplayOrder

Good luck,

-John


More information about the Valentina mailing list