O$: How to use $selectdistinct?

Rob Brandt bronto at csd-bes.net
Thu Dec 2 13:04:27 EST 2010


Yep, thanks (and to Kelly offlist with the same advice) this works.

Rob

On 12/2/10 5:59 AM, Grzegorz (Greg) Pasternak wrote:
> Rob;
> I hope the following may help, this worked for me.
>
> My assumptions:
> - SQL database
> - tSessObj = properly instanciated session object
> - using schemas and table classes
> - 't_Country' = table class that has coresponding 's_Country' schema
> class, subclassed from 't_Super'
> - 'code' = column in 's_Country' schema
> - 's_Country' has many columns
> - 't_Super' = table superclass
> - do not overwrite '$selectdistinct' and '$fetch' in underlying table
> superclass
>
> 1. define list from 't_Country' with 1 column - 'code'
> ------------
> Calculate vDefString as
> con('$definefromsqlclass(',kSq,'t_Country',kSq,',',kSq,'code',kSq,')')
> Do vLst.[vDefString]
> ------------
>
> 2. assign session object
> ------------
> Do vLst.$sessionobject.$assign(tSessObj)
> ------------
>
> 3. issue select distinct to the database on 'code'
> ------------
> Do vLst.$selectdistinct()
> ------------
>
> 4. fetch list of country codes
> ------------
> Do vLst.$fetch(kFetchAll)
> ------------
>
> I am not sure if that is your issue, but if you have overwritten
> '$fetch' and/or '$selectdistinct' then this is where you may have
> trouble as it is common to overwrite '$fetch' and '$select' in table
> superclass.
>
> Regards;
> Greg
>
>
>
> Wiadomość napisana w dniu 2010-12-02, o godz. 02:13, przez Rob Brandt:
>
>> Yes, $select works just fine. And $selectdistinct without parameters
>> works too, except it doesn't know what I want to be "distinct", so it
>> returns most if not all of the data (1300 records). There are really
>> only 4 distinct values currently in the RATELOCATION COLUMN.
>>
>> Rob
>>
>>
>> On 12/1/10 11:05 PM, George Panagopoulos wrote:
>>> Hi Rob,
>>>
>>> Check if a regular $select in the same code gives correct results.
>>> Normally $select and $selectdistinct work exactly the same.
>>> Also try to catch the SQL text that is issued to the database server( on
>>> an OK message). Maybe there is some syntax error there.
>>>
>>> I hope it helped.
>>>
>>> George
>>>
>>> Στις 2/12/2010 3:44 πμ, ο/η Rob Brandt έγραψε:
>>>> I have a need to build a list of distinct values from one column in a
>>>> table. In plain ol' mysql I can get the results I want with:
>>>>
>>>> SELECT DISTINCT `RATELOCATION` FROM `newmainclientpayments`
>>>>
>>>> Where RATELOCATION is the column among 30 columns from the table I
>>>> need.
>>>>
>>>> Seems like it should be something like
>>>>
>>>> Do
>>>> iRateLocationList.$definefromsqlclass($libs.COMMON.$tables.T_NewMainClientPayments)
>>>>
>>>>
>>>>
>>>> Do iRateLocationList.$selectdistinct('RATELOCATION')
>>>> Do iRateLocationList.$fetch(kFetchAll)
>>>>
>>>> But it results in an error. I also tried creating a 1 column schema
>>>> and defining the list with that class, then using $selectdistinct with
>>>> no parameters, which resulted in no data.
>>>>
>>>> TIA
>>>>
>>>> Rob
>>>> _____________________________________________________________
>>>> Manage your list subscriptions at http://lists.omnis-dev.com
>>>>
>>>>
>>>
>>
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
>
> Grzegorz (Greg) Pasternak
>
>
>
>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com




More information about the omnisdev-en mailing list