Hi All,

Just wondering if there is a better approach to dealing with a list of items 
and a table of results. I was hoping there is a method to deal with this 
completely from within the SQL.

For example, if I had this code:

<!--- Delete if nolonger in list--->
<cfquery>
DELETE FROM myTable
WHERE field1 NOT IN ('#FORM.field1#')
AND field2 = '#FORM.field2#'
</cfquery>

<!--- Check if already exists --->
<cfquery name="getOldList">
SELECT field1
FROM myTable
WHERE field2 = '#FORM.field2#'
</cfquery>

<cfset oldList = valuelist(getOldList.field1)>

<cfloop list="#FORM.field1#" index="i">

<!--- Check if already in oldlist --->
<cfif ListFind(oldList, i) EQ 0>

<!--- If not already, then add --->
<cfquery>
INSERT INTO myTable (
        field1,
        field2)
VALUES (
        '#i#',
        '#FORM.field2#')
</cfquery>

</cfif>

</cfloop>
</cfif>

Are there better methods of dealing with this?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7 
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs 
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:268177
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to