Re: Creating hierarchical entities from a single table...

[email protected] Mon, 10 Nov 2003 14:20:53 CDT
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
If you wanted to, you could execute SQL like that by sending SQL directly 
to the server with EOUtilities.rawRowsForSQL.  This will return
NSDictionaries with key/values in it for the returned rows, which should
include the data you need. 

I don't know of any way to get SQL like that to be generated without just 
creating and sending the raw SQL yourself, I don't think you can get EOF
to generate such SQL on it's own. 

You could also just fetch ALL the timecards for a given employee, and do
the arithmetic yourself in-memory to determine the values you need.  Or
fetch all the timecard entries for a given date range, if you don't want
to go back forever in history.  I'd probably do it this way, unless the
number of time-card entries is so large that this becomes prohibitive
performance-wise.  But I suspect it would work fine. 

Hope that helps,
--Jonathan

On Mon, 10 Nov 2003 11:58:08 -0700 Ric Turley wrote:

> I have a Timecard table with fields ID int, Date date, ProjectID int,
> HoursWorked decimal, Activity varchar and EmployeeID int.  In the Timecard
> entity there is also a derived field Week int.
> 
> I need to create access to the timecards for an employee in the form:
> 
>     Week ending 11/2/2003
>         10/27/2003 (8.2 hours)
>             Activity for Project this
>             Activity for Project that
>         10/28/2003 (4.0 hours)
>             Activity for Project this
>         10/29/2003 (3.8 hours)
>             Activity for Project that
>     Week ending 11/9/2003
>         11/3/2003 (8.4 hours)
>             Activity for Project this
>             Activity for Project that
> 
> The old program creates nested collapsing lists with SQL commands like:
>     SELECT <week_formula> as week, <week_end_formula> as week_end,
> sum(hoursworked) FROM timecards WHERE employeeID=1 GROUP BY week ORDER BY
> week     
>     SELECT date, sum(hoursworked) FROM timecards WHERE week=893 AND
> employeeID=1 GROUP BY date ORDER BY date
>     SELECT concat(activity, ' for Project ', projectid) FROM Timecard 
> WHERE
> ID=4457
> 
> What is the best way to recreate this type of hierarchical list in
> EOF from
> a single table?  
> 
> Thanks, 
> Ric Turley
> Zarac Software
> Custom Software Development
> http://www.zarac.com
> Office: (303) 642-3106
> 
> 
> _______________________________________________
> EOF mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/eof
>