SQLSelect Question
Charles Yeomans
yeomans at desuetude.com
Fri Feb 3 11:07:58 CST 2006
On Feb 2, 2006, at 7:51 PM, Chuck Pelto wrote:
>
> On Feb 2, 2006, at 2:18 PM, Ruslan Zasukhin wrote:
>
>> I do not see still why you need ArraySet, but if you need it you can
>> use
>> this way:
>>
>> cursor = db.SqlSelect( "SELECT DISTINCT f1, f2 FROM T" )
>>
>> arrayset = cursor.ToArraySet()
>
> Well...RB doesn't really play with arrays all that well. For example,
> sorting is only for one-dimensional arrays. Whereas sorting a cursor
> of multiple fields is so hard with V4RB2, as I understand it.
>
> So, getting the data and sorting IT in V4RB2 and then passing it to RB
> as an array seemed to me to be the best way to go about getting around
> RB's difficulty in managing arrays.
>
> [1] Get an complex data structure, using the 'SELECT DISTINCT'.
> [2] Sort it using SORT BY.
> [3] Make it available as an array to RB via VArraySet.
> [4] Start 'slicing and dicing' the data into a contextual menu to show
> up in a window of an RB project. [Note: You may or may not have
> noticed the discussion going on over at RB over recusions.]
>
> I think I can really bust some heads in programming my projects if I
> get a handle on this.
REALbasic plays quite well with arrays; perhaps you do not. There is
no canonical notion of total ordering for a multi-dimensional array.
That makes it tough to write a framework method for sorting them.
Instead, the sort of thing you should be doing is to use an object to
hold each row of data. Then you can have a one-dimensional array of
such objects, and that you can sort. If you're reading in the data
from a local database, then perhaps the simplest approach would be to
let Valentina handle the sorting, and then load up the contextual menu
from the cursor.
--------------
Charles Yeomans
More information about the Valentina
mailing list