In its original application, the following "borrowed" code enables data to be
written to a session variable.

I would like to change this so that, a previously established variable, can at
this time be Updated with the current contents.. That is, initially I set the
session variable to capture the Customer ID. In another screen, I want to add
additional data to the original variable. So, I would like to check to see if
the CustomerID is present and if there are NO products already there I want to
UPDATE that row with the new information.

Then, if the CustomerID and same ProductID are there, I want to update that.

I hope that I am making sense.... what this code is currently doing is ADDing
a new row and not updating the appropriate one.

Can anyone offer any advice?



<!--- Update shopping cart --->
<cfelseif attributes.action is "update">
<!--- Loop through basket and remove selected items --->
<cfset newBasket = queryNew("CustomerID, ProductID, ProductName, Quantity,
saleDate")>
<cfloop query="session.basket">
<!--- Add anything that isn't in the delete list --->
<cfif not listFind(attributes.productID, productID)>
<cfset tempValue = queryAddRow(newBasket)>
<cfset tempValue = querySetCell(newBasket, "saleDate", saleDate)>
<cfset tempValue = querySetCell(newBasket, "CustomerID", CustomerID)>
<cfset tempValue = querySetCell(newBasket, "ProductID", ProductID)>
<cfset tempValue = querySetCell(newBasket, "ProductName", ProductName)>
<cfset tempValue = querySetCell(newBasket, "Quantity", quantity)>
</cfif>
</cfloop>
<!--- set the basket to the new values --->
<cfset session.basket = newBasket>
<!--- Add product to query --->
<cfelseif attributes.action is "add">
<!--- check to see if the product is in the baset already --->
<cfset productRow = listFind(valueList(session.basket.productID),
attributes.productID)>
<!--- Product is in basket, update quantity --->
<cfif productRow neq 0>
<!--- determine the new quantity and the correct row --->
<cfset oldQuantity = listGetAt(valueList(session.basket.quantity), productRow)>
<cfset newQuantity = attributes.quantity + oldQuantity>
<cfset tempValue = querySetCell(session.basket, "Quantity", newQuantity,
productRow)>
<!--- Product is not in basket, add it --->
<cfelse>
<cfset tempValue = queryAddRow(session.basket)>
<cfset tempValue = querySetCell(session.basket, "saleDate", "#Now()#")>
<!---<cfset tempValue = querySetCell(session.basket, "saleDate", "#Now()#")>
--->
<cfset tempValue = querySetCell(session.basket, "CustomerID",
attributes.CustomerID)>
<cfset tempValue = querySetCell(session.basket, "ProductID",
attributes.ProductID)>
<cfset tempValue = querySetCell(session.basket, "ProductName",
attributes.ProductName)>
<cfset tempValue = querySetCell(session.basket, "Quantity",
attributes.quantity)>
</cfif></cfif>