Jason,

Whilst it is possible to use R:Base currently (v7.6, at least) with the data 
assumed to be in the order that it was added you should never rely on that 
being the case.

In the Data Browser it can be a very useful happenstance but you must be aware 
that the sequence _could_ be changed for some reason. Furthermore, RBTI may 
need to change the way this happenstance works in the future.

Personally, I make great use of it but I also ensure that any program/command 
uses an order by clause.

Larry beat me to the suggestion of using a view and all that I would add is to 
remember that a temp view could be useful way of creating that view if your 
selection is one that changes.

Regards,
Alastair.

  From: Jason Kramer 
  Sent: Tuesday, March 23, 2010 2:55 PM
  To: RBASE-L Mailing List 
  Subject: [RBASE-L] - Re: LISTOF question


  Larry,
      Thanks.  That works.  I never considered using a view because the table 
is currently ordered (an unlikely to ever get out of order because the PK is an 
autonumber).  I just issued CREATE VIEW myview AS SELECT cols FROM mytable 
ORDER BY mycol.
      I still don't see why R:BASE does not sort the LISTOF.  If I understand 
the normal SELECT process vs. SELECT with an ORDER BY it goes like this:
  NORMAL                        ORDER BY
  Find all matches                    Find all matches
  Display them as found           Sort them
                                              Display them

  I though the sorting after all items are found was what caused the slight 
delay when an ORDER BY clause is used.  I though that a similar process would 
be used with LISTOF

  NORMAL LISTOF                Order BY LISTOF
  Find matches                                Find matches
  Load into list                                Sort them
  Display                                         Load list
                                                      Display


                                                              Thanks,
                                                              Jason

Jason Kramer
University Archives and Records Management
002 Pearson Hall
(302) 831 - 3127 (voice)
(302) 831 - 6903 (fax)
  On 3/23/2010 10:28 AM, Lawrence Lustig wrote: 
    <<
    Should the results of a SELECT LISTOF be sorted if the SELECT command has 
an ORDER BY clause?  
    >>


    No.  Think of what's happening internally in R:Base when you issue that 
SELECT statement:  R:Base is returning a result set with a single row 
containing the result of the LISTOF function.  The ORDER BY clause does, in 
fact, order the result set but since that result set has only a single row in 
it, there's not real meaning to the ORDER BY.


    <<
    If not, is there an easy to way to sort the resulting list, or would I have 
to write a sort routine myself?
    >>



    First, create a VIEW on the table that contains an ORDER BY clause.  Then 
perform your LISTOF query against the view, rather than the original table.
    --
    Larry




------------------------------------------------------------------------------



  No virus found in this incoming message.
  Checked by AVG - www.avg.com 
  Version: 9.0.791 / Virus Database: 271.1.1/2765 - Release Date: 03/23/10 
07:33:00

Reply via email to