Re: Qualify unique values from a tale column
"Jerry W. Walker" <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Sigthor, On May 23, 2006, at 8:28 AM, Sigþór Hrafnsson wrote: > Thanks Jerry > > I thought I might have to go down there, thanks for the confirmation. My response was to meet your stated requirement: "...but I don't want to fetch all the tables to memory, I want to qualify them at the DB level." Before my WO-Dev buds start accusing me of recommending that you drop to the level of raw SQL and result sets unnecessarily (something I overtly try to avoid) let me suggest another option. Any time you drop down to raw rows, you're increasing the complexity of your program (thereby increasing the maintenance burden). May I suggest that you try the raw rows approach and also try simply bringing all the rows as EOs into an NSSet. Let the set cull out the non-unique records, turn the set back into an array and time the two approaches. Unless you have a large table (on the order of a few megabytes or more) and a large percentage of duplicate records (say, 40% or more as a guess), I think you'll find the difference in time will not be all that significant. I could be wrong, but I would do a time test before I ever dropped down to raw SQL. On the other hand, if avoiding raw SQL pushed me into lots of extra memory management, explicit calls to the GC and such, then I would just use the raw SQL approach. Regards, Jerry > > At 12:25 23.5.2006, you wrote: >> Hi, Sigthor, >> >> I think that the only way you're going to pull this one off is to use >> the EOUtilities method: >> >> public static NSArray rawRowsForSQL(EOEditingContext ec, >> String modelName, >> String sqlString, >> NSArray keys) >> >> Then supply a sqlString with "SELECT DISTINCT" to obtain unique >> values for that given column (ip). >> >> You can turn the returned raw row NSDictionaries into full fledged >> EOs using the EOEditingContext method: >> >> public EOEnterpriseObject faultForRawRow(NSDictionary row, >> String entityName, >> EOEditingContext context) >> >> Regards, >> Jerry >> >> On May 23, 2006, at 7:12 AM, Sigþór Hrafnsson wrote: >> >>> This is completely eluding me. >>> >>> I want to qualify based on unique values from a column in a table, >>> like >>> >>> Have a table User with a column ipAddress, in the table there can >>> be more that one user by the same name with the same >>> ipAddress but a different table id. >>> >>> User Table example >>> >>> User john ip 111 id 1 (simplified for demonstration) >>> User Bart ip 222 id 2 >>> User Elsa ip 333 id 3 >>> User john ip 111 id 4 >>> >>> With the EOQualifier, I would like to get the result for table id's >>> 1, 2 and 3 but not 4, or it could also be id's 2, 3 and 4 but not 1. >>> >>> I know how to do the sort in memory, but I don't want to fetch all >>> the tables to memory, I want to qualify them at the DB level. >>> >>> Thanks >>> >>> Sigthor >>> >>> _______________________________________________ >>> WebObjects-dev mailing list >>> [email protected] >>> http://www.omnigroup.com/mailman/listinfo/webobjects-dev >> >> >> -- >> __ Jerry W. Walker, >> WebObjects Developer/Instructor for High Performance Industrial >> Strength Internet Enabled Systems >> >> [email protected] >> 203 278-4085 office >> >> > -- __ Jerry W. Walker, WebObjects Developer/Instructor for High Performance Industrial Strength Internet Enabled Systems [email protected] 203 278-4085 office