Click to See Complete Forum and Search --> : update query not working


ahdacres
03-30-2004, 05:30 AM
I have the following update query ...the form in question comes from the referring page which is coldfusion hence the ## marks for variables what have i done wrong?...I'm getting a syntax error:



The Error Occurred in C:\Projects\AreaPanels\Web\addData\updateGrant2.cfm: line 60

58 : SET comments= '#form.comments#'
59 : WHERE id = #ids#
60 : </cfquery>
61 :
62 :



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

SQL UPDATE community_chest SET ward = 'bingley', SET reference= '543012', SET applicant_name = 'abby', SET applicant_address= 'dalecroft rise', SET organisation= 'newly updated', SET project = 'money needed for holidays', SET date_duration= 'two weeks', SET cost_of_project = '5000', SET amount_requested= '4000', SET decision= 'false', SET comments= 'you are too greedy' WHERE id = 28
DATASOURCE area_panel_grants
VENDORERRORCODE -3503
SQLSTATE 42000

----------------------------------------------------------
here's the code:


<cfif isDefined("form.decision")>
<cfset decision = "true">
<cfelse>
<cfset decision = "false">
</cfif>

<cfquery name="updateGrant" datasource="#DSN_Name#">
UPDATE community_chest
SET ward = '#form.ward#',
SET reference= '#form.reference#',
SET applicant_name = '#form.applicant_name#',
SET applicant_address= '#form.applicant_address#',
SET organisation= '#form.organisation#',
SET project = '#form.project#',
SET date_duration= '#form.date_duration#',
SET cost_of_project = '#form.cost_of_project#',
SET amount_requested= '#form.amount_requested#',
SET decision= '#decision#',
SET comments= '#form.comments#'
WHERE id = #ids#
</cfquery>

buntine
03-30-2004, 06:59 AM
SQL only requires the SET keyword once in an UPDATE query. So, your code should look like this.

<cfquery name="updateGrant" datasource="#DSN_Name#">
UPDATE community_chest SET
ward = '#form.ward#',
reference= '#form.reference#',
applicant_name = '#form.applicant_name#',
applicant_address= '#form.applicant_address#',
organisation= '#form.organisation#',
project = '#form.project#',
date_duration= '#form.date_duration#',
cost_of_project = '#form.cost_of_project#',
amount_requested= '#form.amount_requested#',
decision= '#decision#',
comments= '#form.comments#'
WHERE id = #ids#
</cfquery>


Regards,
Andrew Buntine.

ahdacres
03-30-2004, 07:05 AM
Thanks...works a treat now.