There's a couple of ways this can be handled. But, here's what I usually do.

<cftransaction>
<cfquery....>
Delete * from tblClientCategory WHERE clientid=#form.clientid#
</cfquery>
<cfloop from="1" to="#listlen(form.categoryid)#" index="i">
<cfquery....>
(UPDATE tblClientCategory SET CategoryID=#listgetat(form.categoryid, i)#
WHERE
tblClientCategory.ClientID=#form.clientid#)
</cfquery>
</cfloop>
</cftransaction>

Essentially, instead of trying to test for the existence of the categoryid,
you're just deleting the old and then inserting all the new. <cftransaction>
is optional here. It ensures that if your second (looped) query doesn't
work, that you haven't lost your original data. However, if you're
potentially looping through lots of fields, with non-critical data, you
might consider the tradeoffs.

-Deanna



************************************************************
Deanna Schneider
Interactive Media Developer
UWEX Cooperative Extension Electronic Publishing Group
103 Extension Bldg
432 N. Lake Street
Madison, WI 53706
(608) 265-7923




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to