What you want is this:

<cfoutput query="GetExpOrg">

(diagnostics) row: #currentrow# id: #ExpOrg_ID#<br>

<cfquery datasource="#application.datasource#" name="UpdateExpOrg">
update Project_ExpOrg
set OrgValue=(select org_value from expressionorganism3 
where exporg_id = #ExpOrg_ID#)
where project_id = #url.ProjectId#
</cfquery>

</cfoutput>


Basically, the reference within the query to GetExpOrg.ExpOrg_ID is the 
equivalent to GetExpOrg.ExpOrg_ID[1] outside of a query output context, so 
you always got the first ID, I'm guessing.  CFLOOP sometimes does this, and 
you've found one example.

----------------------------------------

From: "Rick Colman" <rcol...@cox.net>
Sent: Tuesday, November 02, 2010 7:29 PM
To: "cf-talk" <cf-talk@houseoffusion.com>
Subject: What is wrong with this loop update?

I am trying to update multiple rows by looping through:

<cfloop query="GetExpOrg">

(diagnostics) <cfoutput>row: #GetExpOrg.currentrow# id: 
#GetExpOrg.ExpOrg_ID#</cfoutput><br>

<cfquery datasource="#application.datasource#" name="UpdateExpOrg">
update Project_ExpOrg
set OrgValue=(select org_value from expressionorganism3 
where exporg_id = #GetExpOrg.ExpOrg_ID#)
where project_id = #url.ProjectId#
</cfquery>

</cfloop>

my diagnostics give me:

row: 1 id: 2
row: 2 id: 693
so that is ok.

but both rows are updated with the last value (693) instead of being 
individually updated?

What's wrong with this?

TNX if you can help.

Rick.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338788
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to