cpwilson
asked on
Problem Updating Record with Coldfusion
Trying to update a donation record based on donor email address. Field names are this_donation, last_donation, and total_donations. All are numeric fields. Last_donation should be set from amount showing in this_donation, this_donation should become the amount of the donation currently being made, total_donations should become the total of whatever amount is currently shown as total plus the amount of the current donation. update should occur if the donor has previously made donations, else they are entered as new donor.
Currently using following code
<cfquery name='find_record' datasource='#conn#'>
select * from donations where email_address = '#email_address#'>
</cfquery>
<cfquery datasource='#conn#'>
update donations
set last_donation = #find_record.this_donation#,
this_donation = #donation#,
total_donations = (donation + total_donations)
where email_address = '#email_address#'
</cfquery>
Currently using following code
<cfquery name='find_record' datasource='#conn#'>
select * from donations where email_address = '#email_address#'>
</cfquery>
<cfquery datasource='#conn#'>
update donations
set last_donation = #find_record.this_donation#,
this_donation = #donation#,
total_donations = (donation + total_donations)
where email_address = '#email_address#'
</cfquery>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.