Link to home
Start Free TrialLog in
Avatar of mahpog
mahpog

asked on

Mass Upload Load a table directly from a cfquery result set.

I have a cfquery result set that I would like to directly update an existing table.

I would like to do this in coldfusion.  Do I output to hidden fields, add an index and then do a cfloop update command?  - Or is there a better way.



<cfquery name="qdirect" Datasource="#Request.datasource#">
SELECT psid,
SUM(CASE labor_date WHEN '01/01/2007' THEN labor_hours ELSE 0 END) AS jan_salary,
SUM(CASE labor_date WHEN '02/01/2007' THEN labor_hours ELSE 0 END) AS feb_salary,
SUM(CASE labor_date WHEN '03/01/2007' THEN labor_hours ELSE 0 END) AS mar_salary,
SUM(CASE labor_date WHEN '04/01/2007' THEN labor_hours ELSE 0 END) AS apr_salary,
SUM(CASE labor_date WHEN '05/01/2007' THEN labor_hours ELSE 0 END) AS may_salary,
SUM(CASE labor_date WHEN '06/01/2007' THEN labor_hours ELSE 0 END) AS jun_salary,
SUM(CASE WHEN (d_i IN ('D','I')
            and proj_def in ('##')
            and activity_type like 'D%'
            and rcc NOT in ('80507'))
      THEN labor_hours ELSE 0 END ) as oTotal
 FROM a_rollup_labor
 GROUP BY psid
 ORDER BY psid
</cfquery>
************


ASKER CERTIFIED SOLUTION
Avatar of Scott Bennett
Scott Bennett
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mahpog
mahpog

ASKER

Geez,

I had to get my head out of the one by one insert idea I was thinking in the first round of this task.

My gosh, I should have been drinking on this last request.  

Although, I love your techinque for inserting a new row versus updating.

thx!!!